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?

  • \$\begingroup\$ How is your question different from that one you mentioned? It has good answers. \$\endgroup\$
    – Anko
    Commented Feb 18, 2013 at 22:46
  • 1
    \$\begingroup\$ I'm concerned with the restitution value & bouncing specific to Box2d and its mechanics, rather than my own implementation of bouncing. \$\endgroup\$
    – lase
    Commented Feb 19, 2013 at 0:01
  • \$\begingroup\$ On my system 6th ball rapidly lost much of its energy, and then begun bouncing with small amplitude forever. I think, it is some kind of lose-end for box2d. May be, setting some linear damping for the ball can fix it. \$\endgroup\$
    – Pavel
    Commented Feb 19, 2013 at 8:48


You must log in to answer this question.

Browse other questions tagged .