- Home /
Freeze rigidbody position and rotation without overriding the velocity.
A the title states, I would like to way to freeze the position and rotation of a rigid body without changing its velocity. I have tried using isKinematic and RigidbodyConstraints but both seem to set the velocity to 0. I want it to keep its velocity so that when I unfreeze it it will continue on the exact path it should if I never froze it to begin with. How can I do this?
Comment
Just store the velocity in a variable before freezing it. Something like:
public class $$anonymous$$yClass : $$anonymous$$onoBehaviour
{
public Rigidbody myRigidbody;
private Vector3 oldVelocity;
private void Freeze()
{
oldVelocity = myRigidbody.velocity;
myRigidbody.is$$anonymous$$inematic = true;
}
private UnFreeze()
{
myRigidbody.is$$anonymous$$inematic = false;
myRigidbody.velocity = oldVelocity;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612153736im_/https://answers.unity.com/themes/thub/images/avi.jpg)