Description
The LinearDrag
property of the PhysicsBody
class specifies the amount of air drag applied to the linear movement of the physics body. This drag affects the body's linear velocity, slowing it down over time due to air resistance. The default value is 1.
Unlike LinearDamping
, which is a generic damping factor, LinearDrag
should consider the object's rotation and surface area in the direction of movement. This makes it more realistic in simulating air resistance.
For more accurate simulations, consider the AirDensity
property of the PhysicsWorld
and ensure that DragEnabled
is set to true.
Usage
To use the LinearDrag
property, you can set it to a desired value to control how much air drag affects the linear movement of a PhysicsBody
. This can be useful for simulating different environmental conditions or material properties.
Example usage:
PhysicsBody body = new PhysicsBody();
body.LinearDrag = 2.0f; // Sets the linear drag to 2, increasing air resistance.
Ensure that DragEnabled
is set to true for the drag to take effect:
body.DragEnabled = true;
Example
PhysicsBody body = new PhysicsBody();
body.LinearDrag = 1.5f; // Set a custom linear drag value
body.DragEnabled = true; // Enable drag to apply the effect