Skip to main content

rigid_body_sleeping

When a dynamic rigid-body doesn't move (or moves very slowly) during a few seconds, it will be marked as sleeping by the physics pipeline. Rigid-bodies marked as sleeping are no longer simulated by the physics engine until they are woken up. That way the physics engine doesn't waste any computational resources simulating objects that don't actually move. They are woken up automatically whenever another non-sleeping rigid-body starts interacting with them (either with a joint, or with one of its attached colliders generating contacts).

Rigid-bodies are also automatically woken up whenever one of the components of the rigid-body is modified (to apply forces, change its position, etc.) They will not be awaken automatically when changing the gravity though. So you may sometimes want to wake a rigid-body manually by setting the component field Sleeping::sleeping to false: this wakes up the rigid-body as well as the rigid-bodies interacting with it. Setting it to true puts the rigid-body to sleep.

The other fields of the Sleeping component control when the rigid-body falls asleep: it has to move slower than Sleeping::normalized_linear_threshold and Sleeping::angular_threshold during Sleeping::time_until_sleep seconds. A rigid-body can be prevented from ever sleeping by giving it the Sleeping::disabled() component.