I am making a billiards game, so my gravity is set to zero and I apply impulse to make a cue ball move. Because there is no gravity, I use both, linear and angular damping to slow the balls down.
While the balls have some decent velocity, they slow down realistically. The problem start’s when they slowdown a lot and are about to stop but don’t actually stop for like 4-5 seconds, and that’s look’s very unrealistic.
One of the solutions that I thought was to check every frame the velocity of the ball and if it’s bellow some number (i.e. when the ball is about to stop), make it zero to stop the object. The problem with this approach is that I am making a multiplayer game, where two players can have a slightly different frame rate and thus making two simulations of the same shot inconsistent.
Can anyone think of any other solution?
Try to use linear damping parameter of b2Body
:
body->SetLinearDamping(0.1f);