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.
| Component | Role in the rewind | Typical value |
|---|---|---|
| Position history buffer | Stores past hitboxes per entity | About 1 s of ticks |
| Latency estimate | Approximates one-way delay to the shooter | 20-150 ms in practice |
| Interpolation delay | Accounts for the client rendering slightly in the past | 1-2 ticks, often 15-100 ms |
| Rewind limit | Caps how far the server will travel back | Often 200-400 ms |
| Restore step | Returns entities to the present state | Same server tick |
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.
| Approach | How hits are decided | Main trade-off |
|---|---|---|
| Full server rewind | Server rewinds hitboxes to the shooter’s view time | Victims can be hit after reaching cover |
| Capped rewind | Rewind is limited to a maximum delay | High-ping players must lead targets again |
| Client-side hit detection | Client reports hits and server sanity-checks them | Responsive but easier to exploit |
| Projectile fast-forward | Projectile spawns advanced by shooter latency | Close-range projectiles can feel inconsistent |
| No compensation | Server tests against the current state only | Shooter must lead by full 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 compared with related netcode techniques
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.
| Technique | Problem it addresses | Typical genre |
|---|---|---|
| Lag compensation | Hit validation against past target positions | First-person shooters |
| Client-side prediction | Delay between pressing a key and seeing movement | Almost all real-time games |
| Entity interpolation | Jerky motion of remote players between snapshots | Shooters and action games |
| Rollback netcode | Late inputs in peer-to-peer play | Fighting games |
| Tick rate increase | Coarse timing between server updates | Competitive shooters |
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.
| Symptom | Likely cause | Typical remedy |
|---|---|---|
| Shots miss fast targets consistently | Interpolation delay not included in rewind | Add rendering delay to view time |
| Frequent deaths behind walls | Rewind cap too generous | Lower cap and use regional servers |
| Cheaters report impossible hits | Client-side detection trusted too much | Validate distance, angle and timing |
| High-ping players cannot land hits | Rewind cap too strict | Raise cap or improve matchmaking by ping |
| Hits disagree with blood effects | Client shows predicted effects before confirmation | Display server-confirmed feedback |
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.