Description
The ClearForces
method is used to clear any accumulated linear forces that have been applied to a Rigidbody
during the current physics frame but have not yet been applied to the physics body. This is useful for resetting the forces on a Rigidbody
if you want to ensure that no unintended forces affect its movement in the next frame.
Usage
Call this method on a Rigidbody
instance when you need to reset the forces that have been applied to it during the current physics frame. This can be particularly useful in scenarios where you want to ensure that the Rigidbody
starts the next frame without any residual forces affecting its behavior.
Example
// Example of using ClearForces
Rigidbody myRigidbody = new Rigidbody();
// Apply some forces
myRigidbody.ApplyForce(new Vector3(10, 0, 0));
myRigidbody.ApplyForceAt(new Vector3(0, 0, 0), new Vector3(0, 10, 0));
// Clear the forces before the next physics update
myRigidbody.ClearForces();