- Home /
Stop rigidbody from moving after it falls on another rigidbody
I have a rigidbody that falls on another, stationary (kinematic), rigidbody. The rigidbody appears to come to rest but in the inspector I can see very, very minute changes in position and rotation. These changes seem to go on continuously without ever stopping even though the object appears to be still. The problem I have is that I'm going to have a very large number of these rigidbodies falling on the stationary rigidbody and I don't want my game to chew up valuable CPU cycles managing the small movements of all of these objects.
Is there a way I can instruct a rigid body to come to a complete stop after it falls unto another rigidbody? Of course if another rigidbody falls on it, the appropriate motion should occur but then it must eventually go back to a complete stop.
Answer by Muuskii · Jul 22, 2012 at 09:16 PM
Take a look at this:
http://docs.unity3d.com/Documentation/Components/RigidbodySleeping.html
Rigidbody sleeping happens completely automatically. Whenever a rigidbody is slower than the sleepAngularVelocity and sleepVelocity it will start falling asleep. After a few frames of resting it will then be set to sleep. When the body is sleeping, no collision detection or simulation will be performed anymore. This saves a lot of CPU cycles.