Zero-ing out physics in Unity...

Typically you might have an object, and you want to reset it, perhaps send it off screen.

Is it true that the following is the complete, total list (four items) of things you have to reset to put the body “at rest”…

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

thing.localPosition = Vector3.zero; // or whatever
thing.localRotation = Quaternion.identity;

Again, is that the complete list? Thanks

{ Bunn has explained that the ordering is irrelevant - I thought it was relevant. }

I could make a hilarious joke and ask where is the Unity doco on this issue :slight_smile:

Usually resetting velocity and angularVelocity is enough (of course if you want ti to move at a certain position / rotation you can do this).

The inertiaTensor and inertiaTensorRotation shouldn’t be changed. It’s a property of the physics object like the mass, size. It specifies “resistance to changes to its rotation”. A long thin object can be rotated very easy around it’s long axis, but very hard around the other axis. This information is stored in the inertiaTensor. It is calculated once at start. If you want to provide your own tensor you can do it, but setting it to zero doesn’t make much sense :wink:

Usually it’s enough to set isKinematic = true. This will reset all physics variables of that object. When you want to use it again, just set it back to false.

@whydoidoit: The order doesn’t really matter. A position change actually bypass the physics. The two velocities can be reset in any order :wink:

edit
You can also call rigidbody.Sleep(). This will force the RB to sleep for at least one frame. This will cancel all current velocities.