Search Unity

Changing behavior of joint added in playmode

Discussion in 'Physics' started by AaronAteo, May 8, 2020.

  1. AaronAteo

    AaronAteo

    Joined:
    Sep 11, 2019
    Posts:
    7
    I stumbled onto a problem when I added a joint by scripting at runtime:
    The test-setup consists of a cube with a hinge joint and a ball with a configurable joint. When I enter playmode, I add the cube as the connected body of the configurable joint, which allows the ball to pull at the cube, tilting it, but not moving its position at the hinge joint anchor.
    This is the behavior, I'm looking for.
    The problem is that the behavior changes, if I add the hinge joint to the cube in playmode, either with the addcomponent menu, via scripting or if I duplicate the whole object. The cube now also moves along with the sphere.
    This video shows that the same effect can even be achieved by pausing the editor and toggling the cube gameObject off and on:

    The behavior change of the joints toggles back and forth each time I do this.
    Does anyone know why this is happening?