bool Sleeping { get; set; }

robot_2Generated
code_blocksInput

Description

The Sleeping property of a PhysicsBody indicates whether the physics body is currently in a "sleeping" state. Physics bodies automatically enter this state after a period of inactivity to optimize performance. This property can be used to manually wake the body or force it into a sleeping state.

Usage

To check if a physics body is currently sleeping, simply access the Sleeping property. To change the sleeping state, set this property to true to put the body to sleep, or false to wake it up.

Example

// Example of using the Sleeping property
PhysicsBody myPhysicsBody = new PhysicsBody();

// Check if the body is sleeping
bool isSleeping = myPhysicsBody.Sleeping;

// Wake the body up if it is sleeping
if (isSleeping)
{
    myPhysicsBody.Sleeping = false;
}

// Put the body to sleep
myPhysicsBody.Sleeping = true;