What is tunnelling in discrete collision detection, and when does a fast projectile pass straight through a thin wall?
answer
- sampling, not sweeping
- positions checked only at step ends
- distance per step against thickness
- overlap window: wall plus body extent
basics
~20 sTunnelling is a fast body skipping through an obstacle because discrete detection only tests positions at each step's end. When distance per step exceeds the wall's thickness plus the body's extent along its motion, no sampled position may overlap.
solid answer
~50 sDiscrete collision detection samples the world: it moves each body to its end-of-step pose and only then asks what overlaps. A body at speed `v` with step `dt` jumps `v*dt` between samples, and it can only be caught while it sits inside an overlap window as long as the wall's thickness plus the body's own extent along the motion. Once `v*dt` exceeds that window, catching it is luck: a 300 m/s projectile with a 0.02 m radius on a 1/60 s step moves 5 m per step, so a 0.2 m wall catches it about 4.8% of the time (0.24 / 5). A milder form starts earlier: an overlap caught past the wall's middle can be pushed out of the far side. Slow, large bodies against thick walls never notice; fast, small bodies against thin walls do.
go deeper
Recall that discrete detection only looks at positions at the end of each step, so a fast enough body can skip a thin obstacle entirely.
Explain the overlap window, wall thickness plus the body's extent along its motion, compare it with distance per step, and show the arithmetic for a concrete projectile.
Diagnose a report from logged speed and step length, separate full tunnelling from deep overlaps resolved out the far side, and include rotation and single-sided geometry in the check.
Turn the tunnelling condition into content and runtime policy: minimum collider thickness, the longest step the game may run, and which bodies need a continuous remedy at all.
## What discrete collision detection actually checks Most physics simulations advance in **steps**. Each step integrates every body's velocity into a new position, then runs collision detection on the new poses: a **broad phase** shortlists pairs whose bounds overlap, a **narrow phase** measures how deeply each surviving pair interpenetrates, and a solver pushes the pair apart. This is **discrete collision detection**: it looks at the world only at the sampled instants and never at the path between them. **Tunnelling** is what happens when the interesting moment falls between two samples. A projectile is in front of a wall at one step and behind it at the next; at neither sampled position does it overlap the wall, so no pair is ever reported and nothing stops it. Nothing in the pipeline is broken: it was simply never asked about the path. ## The overlap window and the tunnelling condition Picture a sphere of radius `r` flying straight at a wall of thickness `w`. Its centre overlaps the wall's volume for as long as it lies inside a slab of thickness `w + 2r`: from the moment its front touches the near face until its back leaves the far face. Call that the **overlap window** `L`. Between samples the centre moves `s = v*dt`. 1. If `s <= L`, at least one sample must land inside the window, so the overlap is always caught. 2. If `s > L`, whether a sample lands inside depends on the step's phase relative to the wall. With an arbitrary phase, the chance of a catch is `L / s`. 3. Even when a sample lands inside, the overlap may be deep. If the centre has already passed the wall's middle (a depth greater than `r + w/2`), a narrow phase that resolves along the shortest way out pushes the sphere out of the **far** side. This partial tunnelling starts at speeds well below the full-tunnelling threshold. For a body that is not a sphere, `2r` becomes the body's extent along its direction of motion. A long plank flying end-first has a large window; the same plank flying broadside has a window only as large as its thickness. ## A worked example: the projectile and the wall Take the scenario's figures: a projectile of radius 0.02 m, a wall 0.2 m thick, and a fixed step of 1/60 s. The window is `0.2 + 2*0.02 = 0.24` m. | Speed | Travel per step | Chance the overlap is caught | |---|---|---| | 5 m/s | 0.083 m | always, and never deeper than the wall's middle (0.12 m) | | 30 m/s | 0.5 m | 0.24 / 0.5 = 48%, and about half of those catches are past the middle | | 300 m/s | 5 m | 0.24 / 5 = 4.8% | The 30 m/s row is the instructive one: the wall catches the projectile about half the time, and about half of those catches land deeper than 0.12 m, so only about a quarter of shots stop on the correct side if resolution goes the shortest way out. ## Which bodies tunnel - **Fast bodies**: projectiles, vehicles at top speed, debris thrown by an explosion. - **Small bodies**: the window shrinks with the body's own extent, so pebbles tunnel before boulders. - **Thin geometry**: fences, glass panes, and especially single-sided triangle meshes, which have no volume at all and therefore no inside to catch the body in. - **Long steps**: anything that lengthens `dt`, such as a step that stretches with a slow frame, raises `s` for every body at once. - **Fast rotation**: a spinning plank's tips move at angular speed times their distance from the centre, so a body whose centre is slow can still sweep its ends through a wall. ## Diagnosing a tunnelling report 1. Log the body's speed and the step length at the moment it escaped and compute `v*dt`. 2. Compare it with the window: the body's extent along the motion plus the thickness of the geometry it crossed. 3. Check whether the crossed geometry is a closed volume or a single-sided surface. 4. Halve the step as an experiment. If the escape disappears, the cause is sampling, not a missing collider or a wrong collision filter. ## The remedies, in one line each - **Thicker or closed collision geometry**: costs nothing at runtime and widens the window. - **Swept tests**: solve for the time of impact along the straight path between samples. - **Conservative advancement**: step time forward by safe amounts until the bodies meet, which also handles rotation. - **Speculative contacts**: let the solver see a contact before the bodies touch and limit the approach to the gap. - **Substeps**: shrink `dt` for the whole simulation, paying for every body, not only the fast ones. Each costs something different, and choosing among them per body is a judgment of its own.
- Why can a body whose overlap was detected still end up on the wrong side of a thin wall?Detection happened, but deep. If the sample landed after the body's centre passed the wall's middle, the shortest way out of the overlap is through the far face, and a resolver that separates along the minimum penetration direction pushes the body onward. That is why tunnelling starts at speeds below the full threshold: the safe travel per step is about the body's half-extent plus half the wall, not the whole window.
- Does a low frame rate make tunnelling worse if physics runs on a fixed step?Not by itself. With a fixed step, distance per step depends only on speed and step length, so the render rate does not change it. A low frame rate matters when the step stretches with the frame, or when the loop clamps how many steps it runs and lets simulated time fall behind instead. The condition to check is always `v*dt` against the overlap window.
- Can a body whose centre barely moves still tunnel?Yes, through rotation. A thin plank spinning at angular speed `w` moves its tips at `w*r`, where `r` is the tip's distance from the centre, so its ends can sweep through a wall between samples even though its centre is almost still. Any tunnelling check that looks only at linear velocity misses this case.
A strobe light photographing a sprinter crossing a painted line: if the flashes are far enough apart, no photo shows a foot on the line, even though the sprinter certainly crossed it.
- Tunnelling only happens when the frame rate drops.
- Collision detection checks the whole path a body travels during a step.
- Only the body's speed matters, not its size or the wall's thickness.
- Any detected overlap is pushed back out the side the body came from.
- A more detailed render mesh for the wall stops projectiles passing through.