Issue with perfectly elastic collisions

Hi,

I was following along with the DOTS pong example video when I noticed some strange behavior. Even with restitution set to 1 for all objects and no linear damping, I couldn’t get a ball to conserve velocity. Each bounce slowed it down until it ended up resting against a wall.

Some more details to reproduce the issue:

  • Two box physics shapes to serve as walls. Friction set to 0 and “Minimum”, restitution set to 1 and “Maximum.”
  • The walls each have a static physics body.
  • A sphere physics shape is used as the ball with the same friction and restitution settings.
  • The sphere has a dynamic physics body with linear damping 0, gravity factor of 0, and some initial linear velocity to make it hit one of the walls.

Experimenting with the mass on the sphere shows that setting it to the minimum of 0.001 causes it to bounce more times before stopping while a high mass causes it to slow down more quickly. I tried angular damping values from 0 to infinity with no noticeable effect.

Apologies if this is a dumb question, but I couldn’t find anything related after searching around for a while. To me it seems like there is still some linear damping being applied even when set to zero. Mass shouldn’t have an effect on perfectly elastic collisions with no damping, right? Hopefully someone can help shed some light on this.

1 Like

Hey, thanks for reaching out!

Yeah unfortunately this is correct, restitution of 1 doesn’t give you perfectly elastic collisions. The problem is the approximate and speculative nature of the physics solver, where we have to be extremely careful not to gain energy (because things will explode). So we are taking a conservative approach and this is one of the things that come out of that.

With that said, there’s nothing stopping you from finding a perfect scenario for you with restitution (slightly) higher than 1, right? You will get the bigger bounce, but I doubt you’ll ever tweak the scene in a way that it will have the sphere always perfectly bounce back to the same height forever. After a while it will either start bouncing less, or more…

1 Like

Thanks for the reply.

That makes a lot of sense. For such a simple game there’s really no reason not to do the “physics” manually. I was just curious if it could be done with DOTS.

I suppose even in an ideal scenario anything that’s not just parameterized is eventually going to drift due to floating point error stacking up.

That being said, I think you can work around the issue if the physics is simple - make the ball kinematic, register collision events for it and then modify (reflect) the velocity the way you like when collision events occur.