bool AutoSleep { get; set; }

robot_2Generated
code_blocksInput

Description

The AutoSleep property of the PhysicsBody class indicates 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 inactive bodies. 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 state.

Example

// Example of setting the AutoSleep property
PhysicsBody myPhysicsBody = new PhysicsBody();

// Enable auto-sleep
myPhysicsBody.AutoSleep = true;

// Check if auto-sleep is enabled
bool isAutoSleepEnabled = myPhysicsBody.AutoSleep;

// Output: Auto-sleep is enabled: True
// Console.WriteLine($"Auto-sleep is enabled: {isAutoSleepEnabled}");