11 · Physics & collisions · 2D and 3D

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.

Space fireC sweep on/off↑↓ speedTap the scene to fire

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

Stopped 0Went through 0

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.

45 words · one sentence to paste as is

Where it's used

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.

Related concepts

New concepts, in your inbox.

One short email when we add new concepts, plus our weekly roundup of AI tools for game devs. Unsubscribe any time.