Understanding Box2d Restitution & Bouncing

Posted by layzrr on Game Development See other posts from Game Development or by layzrr
Published on 2013-02-18T22:20:50Z Indexed on 2013/10/17 16:28 UTC
Read the original article Hit count: 301

I'm currently trying to implement basketball bouncing into my game using Box2d (jBox2d technically), but I'm a bit confused about restitution.

While trying to create the ball in the testbed first, I've run into infinite bouncing, as described in this question, however obviously not using my own implementation.

The Box2d manual describes restitution as follows:

Restitution is used to make objects bounce. The restitution value is usually set to be between 0 and 1. Consider dropping a ball on a table. A value of zero means the ball won't bounce. This is called an inelastic collision. A value of one means the ball's velocity will be exactly reflected. This is called a perfectly elastic collision.

My confusion lies in that I am still getting infinite bouncing with restitution values at 0.75/0.8. The same behavior can be seen in the testbed under Collision Watching -> Varying Restitution, on the 6th and 7th balls. I believe the last one has restitution of 1, which makes sense, but I don't understand why the second to last ball bounces infinitely (as is happening with my working basketball I've created).

I am looking to understand the restitution concept more fully, as well as look for a solution to infinite bouncing with the Box2d framework. My instinct was to sleep objects that appeared to be moving in very small increments, but this seems like a misuse of the engine. Should I just work with lower restitution values altogether?

© Game Development or respective owner

Related posts about collision-detection

Related posts about physics