Description
The GravityScale
property of the PhysicsBody
class allows you to adjust the effect of gravity on a specific physics body. By default, gravity affects all physics bodies equally, but by modifying this property, you can scale the gravity effect relative to the global gravity setting defined in PhysicsWorld.Gravity
. For example, setting GravityScale
to 2 will double the gravity effect on this body, while setting it to 0.5 will halve it.
Usage
To use the GravityScale
property, simply set it on an instance of PhysicsBody
. This property is a float
and can be set to any positive value to increase or decrease the gravity effect.
Example
// Example of setting GravityScale on a PhysicsBody
PhysicsBody myPhysicsBody = new PhysicsBody();
// Double the effect of gravity on this body
myPhysicsBody.GravityScale = 2.0f;
// Halve the effect of gravity on this body
myPhysicsBody.GravityScale = 0.5f;
// Disable gravity effect on this body
myPhysicsBody.GravityScale = 0.0f;