I have a problem with Box2D when 2 dynamic bodies fall onto a static body located below when their restitution is non-zero. They tunnel through each other instead of a rigid elastic bounce.

If I treat the two falling bodies as bullets, they don't tunnel, but instead stop dead with no bounce.

Everything works correctly when the bottom body is not static.

Large body falling onto a smaller body falling onto another large body

Video demonstrating the problem

How can I get the expected behaviour?

I am using Swift port of Box2D version 2.3.1.

  • \$\begingroup\$ This is one of those problems - especially when the object in the middle of the stack has much less mass than the ones around it - that game physics engines are notoriously bad at solving the way we'd like them to. This talk from Bennett Foddy explains why (at 11 & 16 minutes in). The reason it seems to work better with the dynamic body on the bottom is actually the same tunneling problem on the right: the small body tunnels into the body beneath, which then pushes it out gradually so the top body has time to move away. \$\endgroup\$
    – DMGregory
    Commented Dec 11, 2022 at 15:20
  • \$\begingroup\$ Thank you. However, I looked into similar games such as Incredibots, which use older version of Box2D and their source is publicly available. I didn't see such problems occurring in the very same setting. \$\endgroup\$ Commented Dec 11, 2022 at 16:06


You must log in to answer this question.