Freeze object

Hello,

I’m having an issue with a gameobject moving, let’s see if you can help me:

I have a gameobject (with a rigidbody component, of course) moving pretty fast somewhere on the scene by the collision of a big block. When I hit a button I would like the gameobject to be placed on the centre of the scene and be freeze there.

When I hit that button it is correctly placed on the centre of the scene but it continues moving with the same “force” when pushed by the block…
The placement script is like that:

myGameObject.transform.position = Vector3.zero;
myGameObject.transform.rotation = Quaternion.Euler(0,0,0);

Should I apply something else in order to reset this “temporal applied force”?

Thanks in advance. :?:

Yes, rigid bodies have velocity and angular velocity. You could zero them out like this :

myGameObject.rigidbody.velocity = Vector3.zero; 
myGameObject.rigidbody.angularVelocity = Vector3.zero;

Alternatively, I think if you switch the rigid body to kinematic it’ll stop all movement :

myGameObject.rigidbody.isKinematic = true;

Then you could set it back to false when you want it to start dynamically moving again.

Hope that helps!

Thank you very much, it solved my problem.
:smile: