Description
The Velocity
property of the PhysicsBody
class represents the linear velocity of the physics body in world space. This property is of type Vector3
, which means it contains three components: X, Y, and Z, corresponding to the velocity in each of the three-dimensional axes.
Usage
Use the Velocity
property to get or set the current linear velocity of a PhysicsBody
instance. This can be useful for determining how fast the body is moving in the world or for applying changes to its movement.
Example
// Example of setting the velocity of a PhysicsBody
PhysicsBody body = new PhysicsBody();
body.Velocity = new Vector3(10.0f, 0.0f, 0.0f); // Sets the velocity to 10 units per second along the X-axis
// Example of getting the velocity of a PhysicsBody
Vector3 currentVelocity = body.Velocity;
// Use currentVelocity.X, currentVelocity.Y, currentVelocity.Z to access individual components