- Home /
Rigidbody not responding after toggling isKinematic
I've noticed this issue on the iPad Mini and in the Unity Editor in the last couple of days.
I have a GameObject that I need to be under the control of scripts for some parts of the game and under the control of physics for other parts of the game. Sometimes after I've had isKinematic on the rigidbody set to true and I toggle it back to false the rigidbody does not respond right away. If I toggle the isKinematic on and off in the inspector or if I have another rigidbody collide with it then it starts working again.
For now I'm using a workaround of adding a very small force to the rigidbody in the script after I set isKinematic back to false as a way to "kickstart" the physics. I'm wondering if anybody else has seen this issue or knows what the cause is.
Answer by HarshadK · Aug 20, 2014 at 11:24 AM
When you set the rigidbody to isKinematic then the rigidbody sleeps and when you set isKinematic to be false you also need to wake up your rigidbody in order for it to respond to the physics properly.
Use Rigidbody.WakeUp after you set your rigidbody's isKinematic to false. Something like:
rigidbody.isKinematic = false;
rigidbody.WakeUp();
Answer by Dave xP · Aug 20, 2014 at 11:14 AM
If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore. Didnt you read the docs?
It simply means that velocity and torque and all that stuff will be reseted to no force, no movement, nothing... and thats why you have to readd forces to move it when you set isKinematic to false again.
One thing you could do, is storing the current velocity and torque in a variable before setting isKinematic to true and readd them after you changed isKinematic back to false.
I have read the docs. Be nice. ;)
Your solution would work well if I was trying to pause the rigidbody and then have it pick up where it left off when I'm done. But my problem is that after I set is$$anonymous$$inematic back to false the rigidbody ignores all physics, including gravity, which I shouldn't have to add back.