Lesson 5 of 9 · 28m
Lag Compensation: Rewinding Without Rewriting Reality
Reconstruct what a shooter plausibly saw, bound the rewind window, and defend hit validation against timestamp and interpolation abuse.
Without lag compensation, a player with 90 milliseconds of latency must aim where the target was not quite where they saw it, but where the server thinks it is now. Players experience this as broken hit registration. With unlimited lag compensation, high-ping players can shoot people who appear safely behind cover. The craft is not eliminating latency; it is choosing whose temporal inconsistency you tolerate and bounding the lie.
The timeline you are compensating
When a shooter fires, their view of remote entities is already old because of outbound latency, server processing, inbound snapshot latency, and interpolation delay:
shooter real time server time target render time
press trigger now --------> arrives later --------> target state was even older
server rewind estimate ~= client interpolation delay + half round-trip timeModern engines rarely trust a client-supplied timestamp blindly. They estimate command timing from sequence arrival, measured latency, tick alignment, and the interpolation offset the client was using.
Rewind hit validation
For hitscan weapons, the server stores recent positions and orientations of entities — often simplified hit capsules — then rewinds them to the estimated time of the shot:
RewindTime rewind = estimate_rewind_time(shooter, cmd);
RingBuffer<HitState> states = world.hit_history.for_time(rewind.server_tick);
restore_hitboxes(states);
Hit hit = trace_ray(shooter_eye, cmd.fire_ray);
restore_hitboxes(world.current);
if (hit.entity) apply_damage(hit, cmd.weapon);This answers the question "did the shot make sense from the shooter's delayed perspective?" It does not recreate the exact pixels the client drew. Animation pose, network smoothing, and local prediction introduce approximation.
Bound the window or create time travelers
A rewind window is a maximum amount of history the server is willing to trust. Typical competitive designs think in hundreds of milliseconds, not seconds. If you allow 800 ms of rewind, a lagging or deliberately unstable player can effectively shoot into the deep past.
0-100 ms ordinary broadband compensation
100-200 ms still playable, increasingly unfair to victims
200-300 ms possible cap for tolerant designs
over 300 ms often rejected or degraded rather than fully compensatedVictims deserve protection too. If a target was already server-side behind cover for longer than the compensation window, the shot should not count. Players tolerate imperfect hit registration better than impossible deaths.
Projectiles are not hitscan
Projectile weapons can be simulated forward from a validated spawn time instead of rewinding targets. That creates different abuse questions: when did the projectile really launch, where was the shooter, was the aim direction plausible, and can the client influence projectile velocity or lifetime? Do not apply hitscan rewind logic to systems that have persistent traveling state.
The cheat surface
Attackers love lag compensation because it is intentionally forgiving. Watch for artificial jitter, timestamp manipulation, intermittent packet delaying, duplicated command sequences, impossible latency asymmetry, and shots that cluster at the edge of the rewind window. A lag switch is not magic; it is controlled packet timing used to exploit trust.
Record enough evidence to analyze: server tick, command sequence, measured RTT, interpolation offset, rewind tick, hitbox transform, target current transform, and final damage decision. Without those fields, every argument about hit registration becomes folklore.
Field notes
- Rewind simplified hitboxes, not full animation state, unless you enjoy paying for skeletal evaluation inside the tick loop.
- Interpolation settings on clients must be bounded by the server; otherwise a player can choose extra artificial delay.
- High ping plus packet loss is not the same as stable high ping. Use jitter and loss in abuse detection.
- Lag compensation should improve consistency, not guarantee that the shooter's screen is literally replayed.
Was this lesson helpful?