Skip to main content

300Mind

netcode client prediction lag compensation rollback

Netcode Explained: Client Prediction, Lag Compensation, and Rollback

Every online game has a problem that no amount of good design fully solves. The player presses a button, and the result has to travel across the internet to a server, get processed, and travel back. That round trip takes time. And in a game where every millisecond of input matters, that time feels like the game is broken.

The solutions to this problem are what netcode is. Client prediction, lag compensation, and rollback are three different approaches to making a game feel responsive and fair even when players are physically thousands of kilometres apart. They are used in different types of games for different reasons, and understanding what each one actually does makes a significant difference in how a multiplayer game gets designed and built.

If you are working on a multiplayer game and trying to figure out which approach fits your project, this guide explains all three in plain terms – what they do, how they work, and when to use each one.

Getting these decisions right before production begins is far cheaper than correcting them later. This guide gives you the foundation to make them confidently.

Why Latency Is the Core Problem

Before explaining the solutions, it helps to be clear about the problem.

When you play an online game, your inputs do not affect the game instantly. They travel from your device to a server, the server processes them alongside inputs from every other player, and the results travel back to everyone. This round trip is measured in milliseconds and is called latency or ping.

Low latency – under 50ms – is barely noticeable. High latency – 150ms and above – makes the game feel unresponsive and unfair. The fundamental challenge of multiplayer game networking is making the game feel good even when latency exists and varies constantly.

If you are still deciding whether to build multiplayer into your game at all, it is worth reading about how much it actually costs to develop a game first. Multiplayer infrastructure is one of the most commonly underestimated line items in any game budget.

Three main techniques exist to address the latency problem:

  • Client prediction – making the game feel instant on the player’s side
  • Lag compensation – making hit detection fair even when players see the world at different times
  • Rollback netcode – keeping two clients perfectly synchronised by rewinding and replaying game state

Each one solves a different aspect of the latency problem.

Client Prediction

Client prediction is the technique where the game client does not wait for the server to confirm an action before showing the result. When a player presses the jump button, the client immediately moves the character upward on screen. At the same time it sends the input to the server. When the server responds with the authoritative result, the client compares it to what it predicted and corrects any difference.

Without client prediction, every action feels delayed by exactly your ping. Press jump at 100ms latency and the character waits a tenth of a second before moving. That is noticeable and unpleasant in almost any game genre.

With client prediction, the character moves immediately. The player feels zero input delay. The game feels responsive.

What happens when the prediction is wrong?

This is where server reconciliation comes in. The server is always the authority on what actually happened. If the client predicted the player would jump to position A but the server says they are at position B, because another player pushed them, or a physics interaction resolved differently, the client corrects its position.

This correction can be jarring if it is large. Good netcode minimises corrections by making predictions that are almost always accurate, and applies small corrections smoothly over multiple frames rather than snapping the character instantly.

Teams that are new to multiplayer architecture often discover this during the prototype phase. This is one reason game prototyping timelines for multiplayer games run significantly longer than single-player equivalents. The networking layer alone can double a prototype’s complexity.

Where client prediction is used:

  • Movement in first-person and third-person games
  • Character actions in action games
  • Any interaction where input response time matters for game feel

Most modern multiplayer games use client prediction for movement. Unity’s Netcode for GameObjects and Unreal Engine’s native replication system both support client-side prediction with server reconciliation built in.

Lag Compensation

Lag compensation solves a specific and important fairness problem in games with hit detection, particularly shooters.

Here is the problem it addresses. You are playing an online shooter. You see an enemy running across your screen and you shoot exactly where they appear to be. The shot registers on your client at time T. But because of your latency, the server processes your shot at time T+100ms. By then, the enemy has moved. The server sees your shot hitting empty space and registers a miss, even though you clearly aimed at the enemy.

This is deeply frustrating and feels like the game is broken. Lag compensation fixes it.

How lag compensation works:

The server stores a history of where every player was at every recent point in time, typically the last few hundred milliseconds. When a shot arrives from a client, the server rewinds its world state to the time when the client fired the shot, checks whether the shot hit at that historical position, and registers the result.

From the shooting player’s perspective, the game is fair. They shot where they saw the enemy. The server validates the shot using the world as the shooter saw it.

The tradeoff:

Lag compensation creates an experience that can feel unfair to the player being shot at. They may have already moved behind cover by the time the shot lands, but because the server rewound time, they still get hit. This is sometimes described as dying around corners and is one of the most complained about phenomena in online shooters.

There is no perfect solution to this. Increasing the rewind window makes the experience better for high-latency shooters and worse for targets. Most games cap the rewind window at a certain latency threshold. Players above that threshold get degraded hit detection to protect the experience for everyone else.

Where lag compensation is used:

  • First-person shooters
  • Third-person shooters
  • Any game where hitscan or projectile weapons need fair validation

Rollback Netcode

Rollback netcode is the dominant approach in competitive fighting games and is increasingly used in other genres. It works very differently from the client prediction and lag compensation approaches described above.

The core idea:

Both clients run the same simulation simultaneously. When local inputs arrive, they are applied immediately. The player sees instant response. Remote inputs from the other player travel across the network and arrive slightly delayed due to latency.

When a remote input arrives late, the game does the following:

  1. Rolls back to the game state at the frame where the remote input should have been
  2. Re-applies all inputs from that frame forward, now including the correct remote input
  3. Fast-forwards back to the present
  4. Displays the corrected result

This happens in milliseconds and is often invisible to the player. The game corrects itself constantly and almost imperceptibly.

Why fighting games specifically use rollback:

Fighting games have inputs that matter at the level of individual frames, typically 60 frames per second, so each frame is 16.7ms. A delay-based approach, where inputs are held until both clients have them, introduces visible lag that destroys the feel of the game. Rollback eliminates input delay entirely by running ahead and correcting.

Games like Street Fighter 6, Guilty Gear Strive, and Mortal Kombat 1 all use rollback. The community response compared to older delay-based implementations has been uniformly positive. Rollback feels dramatically better for competitive play.

The requirements for rollback to work:

  • The game simulation must be fully deterministic. The same inputs must always produce exactly the same result on both machines.
  • The full game state must be saveable and restorable quickly. Rollback can require rewinding and replaying multiple frames per second.
  • This works best with a small number of players. Rollback is typically used for one-on-one or small player count games.

For large player count games like battle royale, MMOs, and sports games, rollback becomes impractical because saving and restoring state for dozens of players on every frame is computationally prohibitive.

Where rollback is used:

  • Competitive fighting games
  • Some real-time strategy games
  • Small player count competitive games where determinism can be guaranteed
building a multiplayer game

Comparing the Three Approaches

Each networking approach has its own strengths and trade-offs in responsiveness, complexity, and gameplay accuracy. Here’s how client prediction, lag compensation, and rollback compare.

TechniqueBest forKey benefitMain tradeoff
Client predictionMovement and actions in most genresZero input delay feelRequires server reconciliation and smooth correction
Lag compensationHit detection in shootersFair shooting experienceCan feel unfair to targets at high latency
Rollback netcodeFighting games and deterministic simulationsNo input delay, frame-perfect synchronisationRequires deterministic simulation, breaks at high player counts

Most multiplayer games combine client prediction with lag compensation. Rollback is typically a genre-specific choice for games where determinism is achievable and input precision is the primary concern.

Implementation in Unity and Unreal Engine

Choosing the right networking approach depends on your game’s genre, responsiveness requirements, and engine capabilities. Here’s how Unity and Unreal Engine handle client prediction, lag compensation, and rollback.

Unity

Unity’s Netcode for GameObjects supports client-side prediction with server reconciliation through its NetworkTransform and NetworkRigidbody components. For more control, the community-supported Mirror networking library and Photon Fusion both offer prediction systems that can be customised per project.

For rollback specifically, Unity does not have a built-in rollback solution. Teams implementing rollback in Unity typically build their own state management system or use community tools designed for fighting game development.

Unreal Engine

Unreal Engine’s native replication system is server-authoritative with client prediction built in through Character Movement Component. This is one of the most well-tested prediction implementations in any game engine, having been used in Fortnite and hundreds of other shipped games.

Lag compensation in Unreal is handled through the Gameplay Ability System’s TargetData system, which includes server-side rewind for hit validation. Teams can configure rewind window length per project.

For rollback in Unreal, the engine does not provide native rollback. It is typically implemented as a custom system for specific genres that require it.

If your team is figuring out which networking approach fits your project, 300Mind’s Unreal Engine development and Unity development teams have shipped multiplayer games using all three approaches across both engines.

Which Approach Does Your Game Need?

The decision depends on the genre and the player count more than anything else.

Use client prediction if:

  • Your game has any real-time movement
  • Players need to feel zero input delay
  • You are building on Unreal or Unity with standard networking tools

Use lag compensation if:

  • Your game has weapons or hit detection
  • Players shoot at targets in real time
  • You want hitting enemies to feel fair regardless of the shooter’s latency

Use rollback if:

  • Your game is a competitive fighting game or similarly small-scale deterministic simulation
  • Input precision at the frame level is the core of the game feel
  • You have the engineering resources to implement deterministic state saving and restoration

Most online multiplayer games, shooters, action games, sports games, survival games, use both client prediction and lag compensation together. They are complementary rather than competing approaches. Rollback is a specific tool for a specific type of game.

Frequently Asked Questions

What is rollback netcode and why do fighting games use it?

Rollback netcode is a multiplayer synchronisation technique where both clients run the game simultaneously without input delay. When remote inputs arrive late due to latency, the game rolls back to the correct frame, re-applies all inputs including the late one, and fast-forwards to the present. Fighting games use it because every input matters at the frame level and any input delay makes the game feel unresponsive at a competitive level. Rollback eliminates input delay entirely, making online play feel nearly identical to playing locally.

How does lag compensation work in online shooters?

The server stores a history of player positions for the last few hundred milliseconds. When a shot arrives from a client, the server rewinds its world state to the moment the client fired, checks whether the shot hit at that historical position, and registers the result accordingly. This means the shooting player is validated based on what they saw on their screen rather than where the target has moved by the time the shot reaches the server. The tradeoff is that targets can be hit slightly after moving to safety from their own perspective.

What is client-side prediction in multiplayer games?

Client-side prediction means the game immediately applies player inputs locally without waiting for server confirmation. The character moves as soon as the button is pressed. The client sends the input to the server simultaneously, and when the server responds with the authoritative result, the client corrects any difference. This makes games feel responsive at any latency. Without it, every action would feel delayed by exactly the player’s ping.

Can you use rollback netcode in Unity or Unreal Engine?

Neither Unity nor Unreal Engine has built-in rollback netcode. Both engines support client prediction and server reconciliation natively. Rollback requires a fully deterministic game simulation and a system to save and restore the complete game state on any frame, both of which need custom implementation. Teams building fighting games in Unity or Unreal typically build their own rollback systems or use community tools designed specifically for this purpose.

What is server reconciliation?

Server reconciliation is the process where the client corrects its locally predicted game state to match the server’s authoritative result. When a client predicts a movement and the server disagrees, the server sends the correct state and the client adjusts. Good server reconciliation applies these corrections smoothly over multiple frames to avoid jarring position jumps.

What is the difference between latency and lag compensation?

Latency is the time it takes for data to travel between the player’s device and the server. Lag compensation is a technique servers use to account for that latency when processing hit detection and other time-sensitive game events. Latency cannot be eliminated as it is a physical constraint of distance and network infrastructure. Lag compensation is how games make results feel fair despite latency existing.

Build Your Multiplayer Game With the Right Foundation

Getting netcode right from the start is one of the most important decisions a multiplayer game makes. The wrong architecture chosen early becomes extremely expensive to reverse mid-production, and players feel the difference immediately in how the game responds.

At 300Mind, we build multiplayer games across Unity and Unreal Engine for studios at every stage. We have worked through client prediction, lag compensation, and server-authoritative architecture on real shipped titles and know where the expensive mistakes happen before they happen on your project.

Whether you are designing your network architecture, choosing between engines, or building the game from scratch, our team is available to work alongside yours. Get in touch with best game developers to start a conversation about what your project needs.

Ankit Dave
WRITTEN BY Ankit Dave

Ankit Dave is a Game Development Team Lead with 10+ years of experience building 2D and 3D games, multiplayer systems, AR/VR applications, and cross-platform experiences. Specializing in Unity, Unreal Engine, and Roblox, he helps transform game ideas into scalable, high-performance products from concept to deployment. Ankit is also passionate about creating developer tools, frameworks, and marketplace-ready assets that help studios accelerate production and improve workflows.

Subscribe to our newsletter

Join our subscribers list to get the latest news, updates, and practises on gaming.

Ready to Build Your Game?

Have a game idea or existing project? Let’s discuss your needs and build the right team for it.

Have a Game Idea?

Let’s Build a Game Players Want to Play.