bool Sleeping { get; set; }

robot_2Generated
code_blocksInput

Description

The Sleeping property of the Rigidbody class indicates whether the rigidbody is currently in a sleeping state. A sleeping rigidbody is one that is not actively participating in the physics simulation, typically because it is at rest and not subject to any forces or collisions. This property is read-only and cannot be modified directly.

Usage

Use the Sleeping property to check if a Rigidbody is currently inactive in the physics simulation. This can be useful for optimizing performance by avoiding unnecessary calculations for objects that are not moving.

Example

// Example of checking if a Rigidbody is sleeping
Rigidbody myRigidbody = new Rigidbody();

if (myRigidbody.Sleeping)
{
    // Perform actions knowing the rigidbody is not active in the simulation
    // For example, you might want to wake it up by applying a force
    Vector3 force = new Vector3(0, 10, 0);
    myRigidbody.ApplyForce(ref force);
}