IT lexicon › Programming › Speculative contacts

Speculative contacts

Programming På svenska → Updated: 2026-10-24

A way to stop fast objects tunnelling through walls: create contact constraints ahead of time for pairs that might collide, instead of rewinding to the moment of impact.

Ordinary discrete collision detection only tests where bodies sit at the end of a frame, so a bullet that jumps from one side of a wall to the other in a single step never sees the wall at all. Speculative contacts fix this by looking at the gap between two shapes and their relative speed: if they could meet before the step ends, a contact constraint is added now, with a bound that only bites if they actually close the gap.

The technique was popularised by Paul Firth around 2011 and ships in Box2D, among others. It is cheaper than advancing all the way to the moment of impact, because it reuses the ordinary constraint solver, but the cost is ghost collisions: a body can be braked by an obstacle it would really have missed.

← Back to the lexicon