The AngularVelocity
property of the Rigidbody
class represents the angular velocity of the rigid body in world space. It is a Vector3
value that indicates the rate of rotation around each axis (x, y, z) in radians per second.
The AngularVelocity
property of the Rigidbody
class represents the angular velocity of the rigid body in world space. It is a Vector3
value that indicates the rate of rotation around each axis (x, y, z) in radians per second.
Use the AngularVelocity
property to get or set the angular velocity of a Rigidbody
instance. This property is synchronized across the network, which means changes to it will be reflected on all clients.
To modify the angular velocity, simply assign a new Vector3
value to it. For example, to set the angular velocity to rotate around the y-axis, you can set it to new Vector3(0, 1, 0)
.
// Example of setting the AngularVelocity of a Rigidbody Rigidbody myRigidbody = new Rigidbody(); // Set the angular velocity to rotate around the y-axis myRigidbody.AngularVelocity = new Vector3(0, 1, 0); // Retrieve the current angular velocity Vector3 currentAngularVelocity = myRigidbody.AngularVelocity; // Output the current angular velocity // Note: Avoid using Console.WriteLine in Sandbox // Instead, use in-game debugging tools or UI elements to display this information DebugOverlay.Text(currentAngularVelocity.ToString(), myRigidbody.Position);