Tunneling
Why fast bullets go straight through thin walls.
The game only checks where things are at each frame, not the path in between. A bullet moving 20 pixels per frame can be in front of a 6 pixel wall on one frame and behind it on the next, and no check ever sees them overlap. Checking the path between the two positions, a sweep, catches it.
Try this: Turn speed up and fire a volley: most bullets go straight through. Then press C to switch the sweep on.
where the game checked the bullettunneled through
Fire at the wall.
Prompt bit
Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.
Stop fast objects passing through thin walls: each step, raycast or shape-cast from the previous position to the new one and resolve at the first hit, using physics steps of 1/60 s or smaller, and keep the sweep on even when the frame rate drops.
Fix tunneling for fast objects (bullets, dashes, falling players, balls) in 2D or 3D, any engine. For each fast mover, store the previous position and, each physics step, cast its shape (ray for tiny bullets, circle or sphere otherwise) from the previous to the new position; on a hit, place it at the contact point and run its hit logic. In engines with physics bodies, enable continuous collision detection (CCD) on those bodies only (Unity: Continuous Dynamic; Godot: continuous_cd; Unreal: Use CCD), not on everything. Run physics at a fixed step of 1/60 s or smaller and clamp delta time (0.1 s) so a lag spike cannot make one giant step. Give walls a minimum thickness of at least one step of your fastest object's travel where you can, and cap maximum speeds. For hitscan weapons, skip projectiles and use a single raycast. Add a debug view that draws each step's sweep line.
Where it's used
- Shooters: fast bullets and rockets in 2D and 3D
- Platformers: fast falls through one-tile floors
- Sports and pinball: balls passing through paddles and goals
- Dashes and teleports: moving through enemies or walls in one step
- Physics toys: thrown props escaping the level
Common mistakes
Turning on continuous collision for every object (slow), only fixing it at your own frame rate so it breaks on slower machines, very thin colliders on floors and walls, and forgetting that a long lag spike makes one huge step unless delta time is clamped.
Writing this with an AI assistant? See our best AI coding assistants for game developers.
Missing a concept? Request one.



