clearing forces

Is there a common technique to clear the forces on an object?

I am driving a ball around a maze using forces to move the ball. To add forces to the ball, I am using rigidbody.AddForce(), which is working great. At some points in the game, I want to be able to raise the ball after it falls in a hole. Doing so now causes the existing forces to not be cleared, resulting in a moving ball when it is released. I dont see any way to get the current forces, or a way to clear the forces applied to an object. I tried setting the rigidbody.velocity to zero, but it causes the ball to move really slowly for a few seconds after that, which is not optimal.

try destroying the rigidbody and re-applying it to the ball.

Destroy (rigidbody);
gameObject.AddComponent(Rigidbody);

That’s likely to have an effect similar to zeroing the velocity, which the OP already stated isn’t the desired effect.

@The OP: Forces are cleared automatically every physics step, so you must mean something else.

I can’t quite visualize what you’re describing, but are you wanting to arrest the ball’s motion in a particular direction while allowing it to keep its momentum otherwise? If so, you could probably achieve this by modifying the velocity vector appropriately (rather than just zeroing it), or by applying an impulse with the appropriate direction and magnitude.

If that doesn’t help, maybe you could describe the problem in a little more detail.

thanks for the info! i didnt realize that the forces were being cleared automatically, and i confused that with another bug in my code. What i was seeing a ball that seemed to retain momentum after released. My bug was that i wasnt clearing the direction vector that generates the force vector. So thats why the ball seemed to maintain momentum when it shouldnt be.

thanks again! one of those ‘doh’ moments for me!