bool StartAsleep { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The StartAsleep property of the Rigidbody class determines whether the rigid body should start in a sleeping state when the simulation begins. When set to true, the rigid body will not participate in the physics simulation until it is woken up by an external force or interaction. This can be useful for optimizing performance by preventing unnecessary calculations for objects that are initially at rest.

Usage

To use the StartAsleep property, simply set it to true or false depending on whether you want the rigid body to start asleep or awake. This property should be configured before the physics simulation starts, typically during the initialization of the object.

Example

// Example of setting the StartAsleep property
Rigidbody myRigidbody = new Rigidbody();
myRigidbody.StartAsleep = true; // The rigid body will start asleep

// To wake up the rigid body later, you might apply a force or interact with it
myRigidbody.ApplyForce(new Vector3(0, 10, 0)); // This will wake up the rigid body