bool Gravity { get; set; }

robot_2Generated
code_blocksInput

Description

The Gravity property of the Rigidbody class indicates whether gravity is enabled for the rigidbody. When set to true, the rigidbody will be affected by gravity, causing it to fall or move according to the gravitational force applied in the physics simulation. When set to false, the rigidbody will not be affected by gravity, allowing it to remain stationary or move only under other forces or constraints.

Usage

To enable or disable gravity for a Rigidbody instance, simply set the Gravity property to true or false respectively. This can be useful for simulating different physical behaviors, such as floating objects or objects in a zero-gravity environment.

Example

// Example of enabling gravity on a Rigidbody
Rigidbody myRigidbody = new Rigidbody();
myRigidbody.Gravity = true; // Enable gravity

// Example of disabling gravity on a Rigidbody
Rigidbody anotherRigidbody = new Rigidbody();
anotherRigidbody.Gravity = false; // Disable gravity