Bodies
Learning paths through this topic
A mounted gun snaps around when a second player takes over, or turns the long way round
Turrets and ship cannons that two friends take turns on have a nasty moment: the new gunner looks somewhere else, and the gun jumps to it. Or it spins nearly all the way round because the aim lies just behind the mounting. Here is how a gun swivels sensibly and survives a change of hands.
Tilt a ship on the waves from the water height at its bow, stern and sides
A fleet that bobs up and down together looks like it is on a trampoline, and a ship that only sinks and rises in the middle never tips. Real hulls tilt because the water is at different heights under their ends and sides. This entry shows which points to measure and how to turn their heights into a lift, a nod and a roll.
Make a ship or heavy vehicle steer in a real curve instead of spinning on the spot
Boats in a harbour or trade game that rotate where they float look like toys. A believable ship needs the turn to come from moving forward, and the curve to get wider with speed. This entry gives a simple steering step with a fixed turning circle and a path that closes up exactly.
Shots miss a moving target even though the crosshair was right on its body
The shooter sees the other player a moment in the past, because of lag and smoothing. The server checks the shot against where the body is now, so good aim keeps missing. The cure is to remember where bodies were. Here is the memory and how to look things up in it.
Other players' characters stutter because updates come in a few times a second
In an online game your friend's character jumps from place to place instead of gliding. Drawing the newest known spot is exactly what causes it. Here is the trick that makes remote bodies smooth, what to do when an update is late, and what it costs you.
Let small hits only shake a soldier, and let only big ones knock him out of his swing
If every arrow interrupts the swing of a sword fighter, a crowd of archers makes a whole army stand helpless and twitch. If nothing interrupts it, hits feel like they do not matter. This entry sorts blows into shakes and real staggers, by their size and what the soldier is doing, and prevents the endless stunlock.
Make a smith's hammer or a mallet lift slowly and strike fast, with a small rebound
A worker who swings a hammer with the same smooth up-and-down motion as a pendulum looks like a metronome, and nobody believes the hit. The impact needs a very different speed from the lift, and the exact moment of the blow must be known so sound and sparks can be matched. This entry gives a curve with these properties.
A character climbing stairs bobs in little jumps, but smoothing must not blur real falls
Stairs and kerbs move the body up in sudden small jumps, which makes the picture and the camera shudder. Smoothing everything fixes the stairs and ruins jumps and landings, which then feel floaty. Here is the narrow case that deserves smoothing, and the rule that tells it apart.
Make a snake body or tail follow the head without stretching or cutting corners
Moving each segment toward the one in front with a smooth chase lets the chain stretch when the head is fast and bunch up when it is slow. Segments that copy the head's old positions by time cut corners at different speeds. Here is a simple rule that keeps the spacing fixed.
Adjust speed, stride and posture of units walking up and down hills
Units that march over a hill at the same speed and in the same pose as on flat ground feel pasted onto the map. Going up and going down are not mirror images, and the slope that matters is the one along the walking direction, not the steepest one. This entry turns terrain into the right numbers.
Make a standing soldier turn by stepping its feet once the upper body has twisted too far
Units that stand guard and keep looking at enemies either slide round on the spot like a turntable or twist their spine like a corkscrew. Real bodies do neither. This entry splits the body into two parts and says when the feet should take a step and how big it should be.
Let a marching block step in time, and let it fall out of step smoothly when it charges
A drilled column looks best when every foot hits the ground together, a charging mob when nobody does. Switching between the two in one frame makes the whole army twitch. This entry gives one number per unit that fades the group in and out of step over time, and shows which clock they all share.