I have a Hinge Joint. In a script, I set “Use Motor” to be true when I click on the motor. I see in the inspector that this value does get set correctly. Even though this value is set, the motor doesn’t actually do anything unless I change some value on the Hinge Joint in the inspector. It can be anything; I can change the target velocity/force/free spin of the motor, or just set “Enable Preprocessing” to be true/false on the hinge joint itself. Once I do anything like that, the motor will actually start working. I’ve tried changing one of these values in code, but it doesn’t do anything.
I’m at a loss. Why is this happening, and what can I do to fix it?
Also, I’ve seen this answer in several different threads, but it isn’t working for me:
I’ve also encountered this and devised
a workaround. I’m not sure, but it
seems like changing the constraints of
a joint do not cause the physics
engine to calculate a solution for the
scene. By “prodding” the object whose
joint’s constraints have been changed,
you can force a solution. For me,
after changing the constraints of a
joint, I called AddForce(Vector3.zero)
on the object’s rigidbody. This caused
the new constraints to be enforced.