What is tunneling and why it happens
In video games, physic objects will have an specific position which is updated by the physics engine each frame based on its velocity and any forces applied to it.
Motion depicted with very low frame rate to draw attention to the fact that it is not continuous. Note that although the depiction is 2D, this is not specific to 2D.
When the physics engine computes the new position, it must check for collisions and respond to them. For example, if the new position results in a collision with a wall, the physics engine must compute a collision response (e.g. bouncing) so that the object does not end up stuck in the wall.
Collision depicted. With same low frame rate as before.
However, if the object is moving too fast (or if the frame rate extremely low), the physics engine may compute the new position to be on the other side of the wall. As if the object had, somehow, gone through it. We refer to this as tunneling (as if the object had made a tunnel under or through the wall and ended at the other side).
Tunneling depicted. Frame rate is much lower than before.
Solution to the problem include checking for collisions at multiple steps along the motion of the object…
Multiple checks per frame depicted.
… Or checking against a shape that extends from the old position of the object to its new position. This is known as a "sweep collision detection", and it is integral part of a "continuous physics simulation".
Single shape using to check sweeping motion depicted.
Some other ways to mitigate the problem include:
- Enforcing a maximum speed for objects (e.g. terminal velocity).
- Making thicker walls. Thick geometry is also good to hide some shadow mapping problems, so these go hand-in-hand.
- And more physics frames, of course.
Optimizations are beyond the scope of this answer.