Bodies
Learning paths through this topic
Pick the right one of eight facing pictures without flicker on the borders
Strategy units are often drawn from eight sides. When a unit walks along a direction that sits right between two of them, it flickers back and forth between the pictures every few frames. This entry shows what to compare so the picture changes only when it really should.
Animate far-away units less often without making them move in slow motion
A battle with thousands of units cannot update every skeleton every frame, and updating only some of them naively gives distant soldiers that crawl, or a spike every fourth frame when they all update together. This entry shows how to spread the work evenly and which time step each unit must be given.
Make the steps follow the distance walked so feet do not skate or moonwalk
If a walk animation just runs on a timer, the feet slide over the ground when the character speeds up, slows down, stops or walks backwards. Here is how to drive the stride by distance so each foot plants and stays put.
Turning a character to face left by mirroring makes its left and right feet swap sounds
Mirroring one set of drawings or bones to face the other way is a good shortcut, and brings in quiet mistakes. The angles of the joints turn the wrong way, the held item ends up in the wrong hand, and the sound that belongs to the left foot plays for the right. Here is what to flip, and what must not be.
Footsteps and hit moments play twice, or never, after a lag spike or a loop restart
Sounds and effects are tied to moments inside an animation. When the animation clock skips ahead because of lag, or loops around, the naive check misses events or fires them twice. And a newcomer who joins mid-run should not hear a burst of old footsteps.
Keep a gatherer's load and carried item right when orders change halfway
Villagers get new orders all the time: the tree is gone, the player picks another resource, the storehouse burns. A naive loop then lets them carry wood in their hands while mining stone, or vanish their load. This entry shows the small set of states that keeps the body, the item and the numbers in agreement.
Friends dance together, but the late one is always half a step off
A shared emote looks great when everybody moves as one, and silly when a newcomer starts from the first frame in the middle of someone else's loop. Sending the leader's exact frame costs too much and still arrives late. Here is how a newcomer joins so that nobody can tell.
A player's next update is late and their body runs into a wall or slides on forever
When news from a friend's character stops for a moment, you must guess where they are. Guess too boldly and the body drifts through walls and then snaps back. Guess too timidly and it freezes. Here is a guess that fades out and tells you when to stop trusting it.
Make a rope, chain or hair strand swing and hang without stretching or exploding
A string of points joined by springs jitters, stretches under its own weight or flies apart when the game stutters. A different way of simulating moves the points freely and then pulls each pair back to the right distance. It is simple, steady and handles pinned ends.
Let a character look at things within reason, and relax when they are behind
A head that tracks the player gives life to a shopkeeper or guard, but a head that follows without limits twists like an owl, and one that clamps at the side suddenly snaps to the other side when the player walks behind. Here is a rule that handles every direction.
Reviving a teammate: the helper walks through the body or kneels in the wrong spot
A co-op revive needs two bodies in the right places: the helper beside the fallen player, facing them. Placing the helper at a fixed offset makes them cross over the body or snap across it. Here is how to pick the side and when the revive may begin.
A stagger is cut short or skipped because animation messages arrive out of order
Several things can happen to a body at once: a hit, a swing, a roll. On the screen of a remote player the messages arrive in their own order, so a stagger can vanish under an attack, or a very old message restarts something. Here are the rules that make every screen agree.