- Home /
Trying to turn on a motor on a hinge joint. Won't start moving until I change a value in the inspector.
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.
Answer by Ellis · Jun 19, 2015 at 06:55 PM
Wish I could awnser this but I'm searching for the exact same awnser...
I have had the same problem. With AddForce also not being a workaround. Switching the $$anonymous$$inematic setting on and off worked as a workaround for me.
Answer by spinaljack · Mar 16, 2021 at 03:11 PM
Make sure the rigidbody isn't sleeping:
if(rigidbody.IsSleeping()) rigidbody.WakeUp();
Your answer
Follow this Question
Related Questions
Hinge Joint Motor Force Units? 0 Answers
Hinge Motor Stuck After Hitting Limits 1 Answer
Store Joint Motor as temporary variable? 1 Answer