Description
The AutoSleep
property of the PhysicsBody
class determines whether the physics body is allowed to automatically enter a "sleep" state after a period of inactivity. This can help optimize performance by reducing unnecessary calculations for bodies that are not actively interacting with other objects. For more information on the sleep mechanic, refer to the Sleeping
property.
Usage
To use the AutoSleep
property, simply get or set its value on a PhysicsBody
instance. Setting it to true
allows the body to automatically sleep when inactive, while setting it to false
keeps the body active regardless of its activity level.
Example
// Example of setting the AutoSleep property
PhysicsBody myPhysicsBody = new PhysicsBody();
// Enable auto-sleep
myPhysicsBody.AutoSleep = true;
// Disable auto-sleep
myPhysicsBody.AutoSleep = false;