Math and physics › Physics of motion
Springs and damping: a smooth camera and soft motion
Know first: Motion: velocity, acceleration and the time step, Forces: gravity, friction and drag
A camera eases after the hero. A gun kicks when it fires and settles back. A car rocks over bumps, and a character’s tail lags behind a turn. All of this runs on one pair of ideas: a spring pulls toward a target, and damping stops the swinging. This page explains why a spring swings along a sine and what the damping modes are. It shows why a spring beats smoothing for a camera, how to tune one with numbers that make sense, and why a stiff spring in a game sometimes blows up.
Why this matters
In the lesson on smoothing, the camera covered a fraction of the distance to the hero every frame. It does catch up, but it starts at full speed right away, and it has no inertia to carry it past the target. A spring remembers its velocity, so its motion is smooth at the start and at the end. Springs are everywhere in games: cameras, recoil, vehicle suspension, wobbling interface elements, hair. Learn two knobs, frequency and damping, and you can tune any of them. You will also see why something shakes, lags or flies off.