bounce rules on object physics

Hello,

when I read the bounce tutorial, it’s said that bounce is linked to the velocity returned after a collision.

But when a dynamic object (r1 and r2) hit a static object (ground), the final result does not only depend of the bounce of r1 and r2, but also of the bounce of the ground.

local ground=display.newRect( 200, 600, 500, 20) physics.addBody( ground, "static",{bounce=0.5} ) local r1=display.newRect( 100, 100, 50, 50) physics.addBody( r1,"dynamic",{bounce=1} ) local r2=display.newRect( 200, 100, 50, 50) physics.addBody( r2,"dynamic",{bounce=0} )

When the bounce of the ground is 0.5, r1 always jump infinitely r2 stop quickly.

But with ground’s bounce = 1,  r1 and r2 always jump, despite r2 have a zero bounce value.

So my question is : how work internally the bounce ? How it’s linked with the velocity restitution ?

Is there a " mix " with the two bounce value object colliding like a mathematical formula ?

Thanks,

Yvan.

Please an answer, thanks :smiley:

Good week-end.

Basically, a value of 1 means that 100% of the bounce inertia will be preserved in the collision event. So, if either object has a bounce value of 1, the objects will bounce away at the same velocity they had when they collided. In this case, the ground won’t move (because it’s static) and the dynamic object will bounce away with the same speed it had, but in the other direction.

TL;DR: If either object has bounce=1 any object involved in the collision will bounce away at the same speed.

According to Box2D manual (http://box2d.org/manual.pdf), the bounce of the collision is the max of the bounces of 2 objects

Restitution

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. Restitution is combined using the following formula.

float32 restitution; restitution = b2Max(fixtureA->restitution, fixtureB->restitution);

Restitution is combined this way so that you can have a bouncy super ball without having a bouncy floor. You can override the default mixed restitution using b2Contact::SetRestitution. This is usually done in the b2ContactListener callback.

Please an answer, thanks :smiley:

Good week-end.

Basically, a value of 1 means that 100% of the bounce inertia will be preserved in the collision event. So, if either object has a bounce value of 1, the objects will bounce away at the same velocity they had when they collided. In this case, the ground won’t move (because it’s static) and the dynamic object will bounce away with the same speed it had, but in the other direction.

TL;DR: If either object has bounce=1 any object involved in the collision will bounce away at the same speed.

According to Box2D manual (http://box2d.org/manual.pdf), the bounce of the collision is the max of the bounces of 2 objects

Restitution

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. Restitution is combined using the following formula.

float32 restitution; restitution = b2Max(fixtureA->restitution, fixtureB->restitution);

Restitution is combined this way so that you can have a bouncy super ball without having a bouncy floor. You can override the default mixed restitution using b2Contact::SetRestitution. This is usually done in the b2ContactListener callback.