The effect of one object passing through another due to large movement in one time interval is called tunneling .
Box2D uses continuous conflict detection between dynamic and static objects to solve this problem. However, your case (dynamic vs dynamic) is not handled automatically, so itβs just random throws that throw your objects into a collision of positions at the moment when the collisions are evaluated.
From Box2d Manual :
Typically, CCD is not used between dynamic bodies. This is done in order to be effective. In some game scenarios, you need dynamic bodies to use CCDs. For example, you might want to shoot a high-speed bullet onto a stack of dynamic bricks. Without a CCD, a bullet can tunnel through bricks.
Fast moving objects in Box2D can be marked as bullets. Bullets will perform CCDs with both fixed and dynamic bodies. You have to decide which bodies should be bullets based on your game design. If you decide the body should be considered as a bullet, use the following setting.
bodyDef.bullet = true;
The bullet flag affects only dynamic bodies.
Box2D sequentially performs a continuous collision, so bullets can miss fast-moving bodies.
source share