Spielerando

Punch and impact

Learning paths through this topic

Melee attacks that turn toward the enemy you meant, not one behind you

Swings that go into empty air because the enemy was a little to the side feel unfair, but a magnetic aim that snaps to any nearby enemy feels out of control. Here is how to choose the target, how wide a cone to allow, and how to stop the aim from jumping between enemies.

Platforms and timers are out of step between players

Every computer has its own idea of what time it is, and a moving platform or a countdown that depends on the clock will look different for each player. Asking the host for its time works only if you pick the right answer from several. Here is which one, and how to adopt it without the world lurching.

Speed checks wrongly pull honest players back after a lag spike

A host that checks how far each player moved per message punishes anyone whose connection stalls and then delivers several moves at once. Checking against real elapsed time with a small savings account for bursts treats honest players fairly and still stops speed cheats. Here is the account and its cap.

A player runs off into the wall when their connection hiccups

When news about another player stops for a moment, guessing where they went keeps things smooth, but guessing forever sends them through walls and off the map. A good guess slows down on its own and gives up gracefully. Here is the shape of that guess and the limit that keeps it honest.

A dash is ready on my screen but refused by the host

Cooldowns measured in seconds drift apart between the two computers, so the button lights up before the host agrees. Counting in game steps makes both sides agree exactly, and stamping the request with its own step stops cheaters from reordering time. Here is the check, with the three ways a request can be refused.

Other players smooth on a good connection but jerky on a bad one

A fixed amount of delay for drawing other players is either too short for shaky connections or needlessly long for steady ones. The delay should follow how irregular the news really is. Here is a cheap way to measure that, and the asymmetry that keeps the picture from breathing in and out.

Other players stutter on my screen even though the connection is fine

News about other players arrives in small packages, a few times per second, so drawing them at the latest news looks like a slideshow. Showing them a little in the past makes them glide, at a price you should choose on purpose. Here is how far back to look and what to do when news runs out.

Both players see a different game and nobody knows when it began

When two copies of the game drift apart, the worst part is finding out when. A short fingerprint of the world, swapped every so often, tells you the exact moment of the split. Here is what goes into the fingerprint, what must stay out, and how to compare when one side is behind.

Bullets fired by players with a slow connection start far behind the gun

When the host creates a shot only after your fire message has crossed the network, it starts late and trails behind where it should be. Starting it a little further along fixes the look, but too much of that lets shots appear through walls. Here is the right amount and what to do at obstacles.

The game runs in slow motion or fast-forward after the window loses focus

Online games must advance in equal small time slices so everyone computes the same movement, yet screens refresh at different speeds, and a stalled tab can leave seconds to make up. Catching up all at once freezes the game, ignoring it makes players slow. Here is how to split time and where to give up.

My character visibly snaps when the host corrects its position

Sometimes the host disagrees about where you stand by a hair, and the picture jumps. Smoothing it sounds simple, but blending the wrong thing makes the character swim or lets a real teleport crawl across the map. Here is what to keep, what to fade, and when to simply jump.

I pressed jump at the very edge but the host says I was already falling

A short grace period after walking off a ledge makes jumping feel fair, but on a slow connection the grace period is eaten up by the travel time of the message and the jump is refused. The grace must grow with the connection, within a limit, and a grace jump may only happen once. Here are the numbers and the check.