Lazy Developer
Dev Stuff #12

What does 100 ping actually do in a game? I fired 20 shots at 0 to 200ms to find out

Sometimes in a game you're sure you hit, and it doesn't count. And in the corner it says "ping 100ms." What is that actually doing??

Results of auto-firing 20 shots at the same target while raising ping from 0 to 200ms, with lag compensation on and off

I built a target practice experiment to find out. It fires 20 perfect shots at the center of the target on your screen, and I only changed the ping. At 0ms all 20 hit. At 100ms, only 3.

Ping is a round trip

Ping is how long a signal takes to go from your computer to the game server and back. 100ms is 0.1 seconds. Roughly 0.05 there and 0.05 back.

0.1 seconds sounds tiny, but in a game it's a lot. Your screen and the real world on the server are always that far apart.

Your screen is always the past

When the server says "the enemy is here," that info is already 0.05 seconds old when it reaches your screen. So the enemy you see is the enemy from a moment ago.

You shoot at that, and your shot takes another 0.05 seconds to reach the server. In total, you shot at where they were one ping ago. If they're moving, of course you miss.

Try it: raise the ping and shoot

Change the ping and press "Auto-fire 20." You can also click the target yourself. The red dashed circle is where the target really was when the server judged your shot.

Here's what I got. It varies by a shot or two each run.

PingComp. offComp. on
0ms20 / 20-
50ms20 / 20-
100ms3 / 2020 / 20
200ms1 / 2020 / 20

It's fine up to 50ms, then falls off a cliff at 100ms. The target moves 260px per second, so 50ms shifts it 13px and 100ms shifts it 26px. The target's radius is 22px. 13px is still inside, 26px is outside. Hence the cliff.

So games rewind time

Left like this, high-ping players couldn't hit anything. So many online games use lag compensation.

The server keeps a short history of everyone's positions, and when a shot arrives it rewinds by the shooter's ping to judge it. "On this player's screen, the enemy was right here back then? Hit." Valve, the company behind Counter-Strike, describes this in its developer docs, and says it keeps one second of position history by default.

Turn on lag compensation in the demo and all 20 hit, even at 200ms.

The price: getting hit behind a wall

Nothing is free. Now the person being shot gets the raw deal.

On their screen, they've already ducked behind the wall. But the server rewinds to the shooter's past and decides "you weren't hidden yet." Most "I was behind the wall, how did I die??" moments are this.

In the demo, with compensation on at 200ms, 2 of 20 shots landed "behind the wall." The higher the ping, the further it rewinds, and the more often this happens.

Other things that matter besides ping

  • Tick rate: how many times per second the server updates the world. Riot says VALORANT servers update 128 times a second, about every 7.8ms
  • Interpolation: showing things slightly late on purpose so choppy position updates look smooth. Valve's docs list 100ms as the default
  • Rewind limits: rewind too far and the target gets robbed, so games cap it

In the end, hit detection in online games is about deciding whose screen to trust. Trust the shooter and the target gets robbed. Trust only the server and the shooter does.

The one-line version

At 100ms ping, your screen is 0.1 seconds in the past. Games rewind time so your shots land, and the price is someone getting hit behind a wall.

Sources: Lag Compensation (Valve Developer Community) · Source Multiplayer Networking (Valve Developer Community) · VALORANT's 128-Tick Servers (Riot Games Technology)