Vector3 Velocity { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Velocity property of the Rigidbody class represents the linear velocity of the rigid body in world space. It is a Vector3 value that indicates the speed and direction at which the rigid body is moving. This property is synchronized across the network with a priority level of 2, ensuring that changes to the velocity are propagated to all clients in a multiplayer environment.

Usage

Use the Velocity property to get or set the current velocity of a Rigidbody instance. Modifying this property directly affects the movement of the rigid body in the physics simulation. It is important to consider the effects of other forces and constraints that might be acting on the rigid body when setting this property.

Example

// Example of setting the velocity of a Rigidbody
Rigidbody myRigidbody = new Rigidbody();
myRigidbody.Velocity = new Vector3(10, 0, 0); // Sets the velocity to 10 units per second along the x-axis

// Example of getting the velocity of a Rigidbody
Vector3 currentVelocity = myRigidbody.Velocity;
// Use currentVelocity for further calculations or logic