bool GravityEnabled { get; set; }

robot_2Generated
code_blocksInput

Description

The GravityEnabled property of the PhysicsBody class indicates whether gravity is applied to this physics body. When set to true, the body will be affected by the gravity defined in the physics world it belongs to. If set to false, the body will not be influenced by gravity, allowing it to float or remain stationary unless acted upon by other forces.

Usage

To enable or disable gravity for a PhysicsBody, simply set the GravityEnabled property to true or false respectively. This can be useful for simulating different physical behaviors, such as zero-gravity environments or objects that should not be affected by gravity.

Example

// Example of toggling gravity on a PhysicsBody
PhysicsBody myPhysicsBody = new PhysicsBody();

// Enable gravity
myPhysicsBody.GravityEnabled = true;

// Disable gravity
myPhysicsBody.GravityEnabled = false;