IT lexicon › Programming › Sleeping bodies

Sleeping bodies

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

How a physics engine stops paying for objects that are just lying there.

A crate on the floor gets pulled down by gravity every frame, and the contact solver pushes it back up by exactly as much every frame. Net motion: zero. Cost: full price. So nearly every physics engine lets a rigid body fall asleep once its velocity has stayed below a threshold for a while – half a second by default in Box2D. A sleeping body is skipped by the integrator and solver but still takes part in collision tests.

It wakes on a new contact, an applied force, or when whatever it rests on moves. The classic bug is teleporting a body by setting its position without waking it, which leaves a stack of crates hovering in mid-air, serenely convinced the floor is still there.

← Back to the lexicon