Lag compensation

On this page 7

Lag compensation is a server-side netcode technique that rewinds the game world to the moment a player actually fired, so that a hit is judged against what that player saw on screen rather than where targets are at the instant the command arrives. In gaming, and especially in competitive shooters, it is one of the main tools for keeping gaming performance feeling fair when every client has a different network delay.

Without it, players would have to lead their aim by their own ping, aiming ahead of moving targets in proportion to network latency. Lag compensation removes that burden from the shooter, but it shifts a cost onto the target, which is why it sits at the center of debates about hit registration, peeker’s advantage and being shot behind cover.

How lag compensation rewinds the server state

Lag compensation works by keeping a short history of every player’s position on the authoritative server and replaying a past moment when it validates a shot. The server stores hitbox snapshots for each tick, typically covering the last 200 to 1,000 milliseconds, and discards older entries.

When a fire command arrives, the server estimates the shooter’s view time. That estimate combines the measured round-trip latency, the client’s interpolation delay and the tick number embedded in the command. The server then moves every relevant hitbox back to that historical position, performs the ray trace or projectile test, records the result and restores the present state, all within a single simulation step.

The following table lists the components that a typical implementation needs and what each one contributes to the rewind.

ComponentRole in the rewindTypical value
Position history bufferStores past hitboxes per entityAbout 1 s of ticks
Latency estimateApproximates one-way delay to the shooter20-150 ms in practice
Interpolation delayAccounts for the client rendering slightly in the past1-2 ticks, often 15-100 ms
Rewind limitCaps how far the server will travel backOften 200-400 ms
Restore stepReturns entities to the present stateSame server tick
Core components of a lag compensation system

The interpolation delay is easy to overlook but essential. Clients usually render remote players between two received snapshots, so what a player sees is already slightly older than the latest server data. A correct rewind must subtract this rendering delay as well as network latency, or shots will consistently miss by a few centimeters on fast-moving targets.

Variants and design choices

Developers implement lag compensation in several forms, and the choice of model determines who benefits and who pays when latency is high. Hitscan weapons, projectiles and melee attacks often use different rules within the same game.

ApproachHow hits are decidedMain trade-off
Full server rewindServer rewinds hitboxes to the shooter’s view timeVictims can be hit after reaching cover
Capped rewindRewind is limited to a maximum delayHigh-ping players must lead targets again
Client-side hit detectionClient reports hits and server sanity-checks themResponsive but easier to exploit
Projectile fast-forwardProjectile spawns advanced by shooter latencyClose-range projectiles can feel inconsistent
No compensationServer tests against the current state onlyShooter must lead by full latency
Common approaches to compensating for latency

Most modern competitive shooters combine a server-authoritative rewind with strict validation. A rewind cap is the most common safeguard: once a player’s latency exceeds the cap, the excess delay is no longer compensated, which protects other players from extreme behind-cover deaths at the cost of a worse experience for the high-ping player.

Lag compensation is only one part of netcode, and it is often confused with techniques that solve different problems. It corrects where a target was when a shot was fired; it does not hide the shooter’s own movement delay or resolve conflicting inputs.

TechniqueProblem it addressesTypical genre
Lag compensationHit validation against past target positionsFirst-person shooters
Client-side predictionDelay between pressing a key and seeing movementAlmost all real-time games
Entity interpolationJerky motion of remote players between snapshotsShooters and action games
Rollback netcodeLate inputs in peer-to-peer playFighting games
Tick rate increaseCoarse timing between server updatesCompetitive shooters
How lag compensation differs from neighboring concepts

Tick rate interacts directly with compensation quality. At 64 ticks per second the server has about 15.6 ms between snapshots, while 128 ticks halves that gap, so rewound positions are closer to what clients actually rendered. Rubber banding, by contrast, is a symptom of prediction corrections and packet loss, not of lag compensation itself.

Side effects players notice

Lag compensation produces visible side effects because the shooter and the target never share the same timeline. The server must favor one player’s view, and the standard choice is favor the shooter.

  • Shot behind cover: the target reached a wall on their screen, but the shooter saw them in the open a moment earlier, and the server accepts that view.
  • Peeker’s advantage: a player moving around a corner sees the defender slightly before the defender sees them, partly because compensation and interpolation add delay to the defender’s view.
  • Trading kills: two players can both land fatal shots within the same compensation window, producing simultaneous eliminations.
  • Perceived bad registration: a hit that looked clean can be rejected when packet loss or a rewind cap invalidates the shooter’s timeline.

These effects grow with the combined latency of both players. A match between two players at 20 ms feels nearly seamless, while a 150 ms shooter facing a 20 ms target produces frequent behind-cover deaths for the low-latency player.

Practical tuning and common mistakes

Tuning lag compensation is a balance between responsiveness for shooters and fairness for targets, and the right settings depend on matchmaking, server placement and weapon design. The table below links frequent problems to their usual causes and fixes.

SymptomLikely causeTypical remedy
Shots miss fast targets consistentlyInterpolation delay not included in rewindAdd rendering delay to view time
Frequent deaths behind wallsRewind cap too generousLower cap and use regional servers
Cheaters report impossible hitsClient-side detection trusted too muchValidate distance, angle and timing
High-ping players cannot land hitsRewind cap too strictRaise cap or improve matchmaking by ping
Hits disagree with blood effectsClient shows predicted effects before confirmationDisplay server-confirmed feedback
Symptoms, causes and remedies in compensated hit detection

A frequent developer mistake is to use unbounded rewind, which lets a player with an unstable connection exploit large delays. Another is to trust client-supplied timestamps without checking them against measured latency, which opens the door to backtracking cheats that deliberately claim older view times. For players, the most effective fixes are a wired connection, a nearby server and stable frame pacing, because local stutter also distorts what the client renders.

The short version

Online games always run a little behind for each player, because information needs time to travel over the internet. Lag compensation lets the game server look back in time and check what you actually saw when you pulled the trigger.

Think of a referee reviewing a replay instead of judging only what is happening right now. The result is that your aim counts as you saw it, even with some delay. The price is that the other player can occasionally be hit after they believed they were safe.

Where it makes a difference

A team of developers runs a tactical shooter on 64-tick servers in several regions. Playtest reports show that players at 90-120 ms keep dying around corners and complain about bad hit registration, while low-ping players say their shots are fine.

Logs reveal that the server rewinds up to one full second, so high-latency shooters regularly hit targets that had already reached cover. The team caps rewind at 200 ms, adds interpolation delay to the view-time calculation and tightens matchmaking so most lobbies stay below 80 ms.

After the patch, behind-cover death reports fall noticeably, while players inside the normal latency range see no change in responsiveness. The few players above the cap must lead moving targets slightly, which the team accepts as the fairer outcome.