skip to content

Which bodies in a racing game should get continuous collision detection, and how do you weigh it against substeps and thicker colliders?

level: principalimportance: should knowfreq 35%

answer

  1. consequence of failure per body
  2. speed times step against thinnest wall
  3. fix content before paying at runtime
  4. substeps tax every body
  5. dynamic-versus-static first

basics

~20 s

Give continuous collision only to bodies that move farther per step than their size plus the thinnest geometry they meet, and whose escape would break the game, like cars against barriers. Thicken thin content first; substep only if everything needs it.

solid answer

~50 s

At 60 m/s on a physics step stretched to 1/20 s, a car moves 3 m per step, so it can meet a thin fence rail nearly 3 m deep, past its own centre, and be pushed out the wrong side. The cheapest fix is content: barriers with real thickness and closed volumes, a minimum collider thickness enforced by a validation tool, and a physics step that a slow frame cannot stretch. Then I flag by consequence: player and opponent cars get continuous collision against static geometry, because leaving the track ruins a race; cones and debris do not, because one through a fence goes unnoticed. Speculative contacts make a cheap default; swept time-of-impact goes to the few bodies that need precision. Substeps fix everything at once but multiply the cost of every body, so I take them only if the handling model needs them anyway, and I test on the longest step the game can produce.

go deeper

for a junior

Recall that continuous collision costs CPU time, so it is turned on only for bodies that move fast relative to their size and the walls they meet.

for a middle

Explain how speed per step, body size and wall thickness decide whether a body is at risk, and name the cheaper fixes before runtime ones.

for a senior

Diagnose which fix fits a reported escape, and explain the hidden costs of each remedy: lost time, serial impact processing, ghost bumps and pair growth.

for a principal

Own the policy: classify bodies by consequence, set content rules and step limits, budget the worst-case frame, and verify it with fire tests and field telemetry.

## Start from the failure, not the feature **Continuous collision detection** (CCD) is any method that considers a body's path between simulation samples instead of only its sampled positions. Every form of it costs CPU time, and the question a lead owns is where that time buys something players notice. The reserved scenario: a racing car at 60 m/s on a physics step that has stretched to 1/20 s, because the step follows a slow frame. Each step moves the car `60 / 20 = 3` m. A car about 4.5 m long hitting a fence rail 0.1 m thick head-on will usually be caught overlapping, because its own length exceeds the travel, but the overlap can be almost 3 m deep. Its centre, 2.25 m behind the nose, can then be past the rail, and a resolver that separates along the shortest way out pushes it through. The same car sliding sideways, about 2 m wide, can skip the rail entirely. Writing down this arithmetic per body class is the first step of any policy. ## The remedies and what each costs | Remedy | Fixes | Cost | Typical failure | |---|---|---|---| | Thicker, closed collision geometry | every body, against that geometry | content work, no runtime cost | thin decorative props nobody thickened | | Fixed or bounded physics step | every body | possible slow motion under load | the loop design decides it, not physics | | Speed caps | the capped bodies | gameplay feel | caps that players notice | | Substeps | every body | simulation cost multiplied by the substep count | still a threshold, just a higher one | | Speculative contacts | flagged bodies | extra contacts and enlarged bounds | ghost collisions near edges | | Swept time of impact, against static geometry | flagged bodies | a search per flagged body | lost time at impact | | Swept time of impact, between dynamic bodies | flagged pairs | a search per pair, plus re-checks | cost grows with pair count | The top rows are the cheapest per problem solved, which is why the policy works down the table, not up it. ## A flagging policy 1. **Classify bodies by consequence.** Player and opponent cars leaving the track is game-breaking. A cone through a fence is invisible. A wheel through the road surface drops the car out of the world. 2. **Compute the risk per class.** Compare the top speed times the longest step with the class's own extent along its motion plus the thinnest geometry it can hit, and remember that a centre crossing the geometry's middle is already a failure. 3. **Prefer dynamic-versus-static.** Most visible tunnelling is a fast body through the static world. Car-versus-car contacts involve two large bodies whose combined length usually exceeds their relative travel per step, and dynamic-pair CCD is far costlier. 4. **Enable automatically above a threshold.** A per-body rule such as 'continuous collision when speed times step exceeds a fraction of the smallest extent' spends nothing on parked or slow bodies. 5. **Budget the worst case.** A twenty-car pile-up with every car flagged is the frame that matters; profile it, not a lap with one car. 6. **Keep projectiles out of rigid-body CCD.** A projectile that only needs a hit result is cheaper as a swept query along its path each step than as a flagged rigid body. ## Costs that hide - **Lost time**: halting a body at its time of impact and dropping the rest of the step makes fast bodies look sticky at every contact. - **Serial work**: processing impacts in time order, earliest first, is hard to spread across threads, so a time-of-impact phase can dominate a frame on a many-core machine. - **Pair growth**: speculative margins and swept bounds enlarge broad-phase boxes, so a fast car drags more candidate pairs through every step. - **Ghost collisions**: speculative contacts near barrier ends and kerbs produce bumps that players report as handling bugs. - **Substeps that were needed anyway**: stiff suspension and tyre models often need short steps for stability. When they do, substeps fix tunnelling as a side effect, and paying for CCD on top may be wasted. ## Verifying the policy - **Test at the longest step** the game can produce, not at the development machine's comfortable frame rate. - **Automate fire tests**: launch each flagged body class at every barrier type at top speed, from several angles, and count escapes. - **Count escapes in the field**: a cheap check that a car has left the drivable volume, reported as telemetry, shows whether the policy holds in real races. - **Keep a content rule**: a validation step that rejects collision geometry thinner than the agreed minimum stops the problem from returning with the next track. No single answer fits every game: a slow puzzle game may need none of this, while a fast shooter may route most fast bodies through queries instead. The decision is the policy, written down, measured and enforced.

  • Why is continuous collision between two dynamic bodies costlier than against static geometry?
    Both bodies move, so both poses must be interpolated and the search runs on their relative motion. The work scales with the number of flagged pairs rather than flagged bodies, and resolving one impact changes both paths, which can invalidate impacts already found and force re-checks. Against static geometry only one body moves and the world stays fixed.
  • What is lost time in time-of-impact handling, and why do players notice it?
    When a body is advanced only to its time of impact and the rest of the step is dropped, it forfeits part of its motion at every impact. A car scraping along a barrier impacts nearly every step, so it slows unnaturally and feels sticky. Re-simulating the remaining time or using speculative contacts avoids it.
  • When are substeps the better tunnelling remedy despite their cost?
    When the simulation already needs them for stability, such as stiff suspension or tyre models, when most bodies in the scene are fast, or when the team wants one uniform behaviour instead of per-body flags. Their cost scales with the whole simulation, so they win only when that cost is being paid for another reason.

  • Turn continuous collision on for every body, just to be safe.
  • Continuous collision is free once the middleware supports it.
  • Substeps are always cheaper than per-body continuous collision.
  • Thin barriers are fine because continuous collision catches everything.
  • Debris and the player car deserve the same collision guarantees.