- Home /
Pause GameObject motion
Hi there, What is the best way to completely freeze an object?
I have a ball that bounces. I've tried:
rigidbody.velocity=Vector3.zero;
But there seems to be "drift" upwards, even when the velocity is zero/gravity off. (is there still acceleration?)
also, just out of curiosity,i tried:
rigidbody.constraints=RigidbodyConstraints.FreezeAll;
But on "RigidbodyConstraints.None", the object does not behave correctly.(it seems that only some of the constraints are lifted, because it only moves/rotates in certain axis) Is this still supported by unity? the documentation is a little lacking.
Thanks all!
Answer by Joshua · Jul 29, 2011 at 04:49 PM
Setting the velocity to zero is correct, but remember to also set the angular velocity to zero.
rigidbody.angularVelocity = Vector3.zero;
If you also don't want new forces to be applied on this game object, because it's for instance on a slope, you can either also turn it to isKinematic=true or go with constraints. Thing is, there's a bug with FreezeAll, so I'd go with setting it to
rigidbody.isKinematic = true;
Your answer
Follow this Question
Related Questions
How do I query the RigidbodyConstraints? 3 Answers
Can I freeze and make objects see-through? 1 Answer
How to freeze child gameobject rotation??? 2 Answers
My code freezes Unity... 1 Answer