Prediction Basics
With an authoritative server, every action makes a round trip: press a key, send it to the server, wait for the result. At 100 ms ping that feels like moving through mud. Client-side prediction hides the delay: the client applies its own input immediately, the server runs the same input authoritatively, and when the server's answer arrives the client reconciles, accepting the result or correcting itself.
Unreal predicts two big things for you:
| System | What it predicts |
|---|---|
UCharacterMovementComponent |
walking, jumping, falling, crouching, root-motion montages for the locally controlled character |
| Gameplay Ability System | ability activation, costs, cooldowns, gameplay effects and cues (with LocalPredicted abilities) |
Most "my multiplayer movement stutters" problems come from code that changes movement outside these systems.
How CharacterMovement prediction works
- Each frame the owning client builds a move (input acceleration, jump flag, timestamp, delta time), performs it locally, stores it in a list of saved moves, and sends it to the server (compressed, often combined with similar moves).
- The server performs the same move from its own state and compares the resulting position with the client's.
- If they match within tolerance, the server acknowledges the move; the client drops older saved moves.
- If not, the server sends a correction (its position and velocity at that timestamp). The client snaps to it and replays every saved move after that timestamp, arriving at a corrected present.
- Other clients see simulated proxies: smoothed, interpolated positions, not predictions.
Debugging tools: p.NetShowCorrections 1 draws corrections in the world, and p.NetCorrectionLagTolerance and related CVars tune tolerances. Simulate bad networks with Net PktLag=150, Net PktLoss=5 in the console, or in Editor Preferences → Level Editor → Play → Multiplayer Options → Network Emulation.
Changing movement correctly
Changing MaxWalkSpeed on the client only (a sprint key handled locally) causes constant corrections: the client predicts at 900 cm/s, the server simulates at 600 and pulls the client back. Changing it with a Server RPC is better, but the change arrives a ping later than the moves that use it, so corrections still happen at the start and end of a sprint. The robust options:
- GAS: a sprint ability that applies a
MoveSpeedeffect, predicted locally and confirmed by the server. The movement component reads the attribute on both sides. - Custom saved-move flags: extend
FSavedMove_CharacterandFCharacterNetworkMoveDataso the sprint flag travels inside each move, which means client and server apply it on exactly the same moves. Powerful, verbose, and documented in many community examples. LaunchCharacterand root-motion sources (FRootMotionSource_ConstantForceand friends) for dashes and knockbacks, which the movement component knows how to predict.
A runnable model: prediction and reconciliation
The model runs a client and a server for one axis of movement, with 3 ticks of latency each way. The client predicts each input immediately. The server caps speed at 6 units per tick, the authoritative rule; the client mistakenly predicts a sprint speed of 9 on ticks 4–5, as if a sprint key had been handled only locally. When the server's correction arrives, the client snaps to the server position and replays its unacknowledged moves.
#include <algorithm>
#include <deque>
#include <iostream>
#include <vector>
struct Move { int Seq; int Input; int Speed; }; // Input: -1, 0, +1
struct Ack { int Seq; int Pos; };
int main() {
const int latency = 3, serverMaxSpeed = 6;
std::vector<int> inputs = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
std::vector<int> clientSpeed = {6, 6, 6, 9, 9, 6, 6, 6, 6, 6, 6, 6}; // ticks 4-5: local "sprint"
int clientPos = 0, serverPos = 0;
std::deque<Move> saved; // client's unacknowledged moves
std::vector<std::pair<int, Move>> toServer; // (arrival tick, move)
std::vector<std::pair<int, Ack>> toClient; // (arrival tick, ack)
for (int tick = 1; tick <= 10; tick++) {
// 1. Client: predict this tick's move immediately and send it.
if (tick <= (int)inputs.size()) {
Move m{tick, inputs[tick - 1], clientSpeed[tick - 1]};
clientPos += m.Input * m.Speed;
saved.push_back(m);
toServer.push_back({tick + latency, m});
}
// 2. Server: process moves that arrived, with its own rules.
for (auto& [arrive, m] : toServer)
if (arrive == tick) {
serverPos += m.Input * std::min(m.Speed, serverMaxSpeed);
toClient.push_back({tick + latency, {m.Seq, serverPos}});
}
// 3. Client: reconcile with acks that arrived.
for (auto& [arrive, a] : toClient)
if (arrive == tick) {
while (!saved.empty() && saved.front().Seq <= a.Seq) saved.pop_front();
int replay = a.Pos;
for (auto& m : saved) replay += m.Input * std::min(m.Speed, serverMaxSpeed);
if (replay != clientPos) {
std::cout << " tick " << tick << ": correction for move " << a.Seq << ": server pos " << a.Pos
<< ", replay " << saved.size() << " moves -> " << replay << " (was " << clientPos << ")\n";
clientPos = replay;
}
}
std::cout << "tick " << tick << ": client " << clientPos << ", server " << serverPos << "\n";
}
}tick 1: client 6, server 0
tick 2: client 12, server 0
tick 3: client 18, server 0
tick 4: client 27, server 6
tick 5: client 36, server 12
tick 6: client 42, server 18
tick 7: correction for move 1: server pos 6, replay 6 moves -> 36 (was 42)
tick 7: client 36, server 24
tick 8: client 36, server 30
tick 9: client 36, server 36
tick 10: client 36, server 36
The client runs three ticks of movement ahead of the server (the one-way latency): it shows the present while the server lags behind. The two bad sprint ticks put the client 6 units too far, and the first acknowledgement that arrived, at tick 7, already revealed the mismatch: the client snapped back from 42 to 36. In a real game that pull is the visible "rubber-banding". Note also that the replay used the server's speed rule. In Unreal, replay runs the client's normal movement code again; the move flags carry state such as "sprinting" so that client and server agree.
GAS prediction in one paragraph
A LocalPredicted ability activates on the client at once with a prediction key. Effects it applies locally (cost, cooldown, a speed buff) and cues it triggers are tagged with that key. The server activates the same ability; if it succeeds, the key is confirmed and the server's replicated effects replace the predicted ones; if it fails (the server thinks you were stunned), the key is rejected and every predicted change rolls back. Not everything can be predicted: removing effects and some attribute changes are server-only. GAS documentation and the community GAS documentation list the limits.
Test yourself
What does the client do when CharacterMovement receives a correction?
- Ignores it
- Snaps to the server's position at that timestamp and replays the saved moves after it
- Disconnects
- Waits for the next correction
Why does changing MaxWalkSpeed only on the client cause rubber-banding?
- MaxWalkSpeed isn't replicated
- The server simulates the same moves with the old speed and corrects the client
- It disables prediction
- It breaks the NavMesh
Which console command simulates 150 ms of extra latency?
- stat net 150
- Net PktLag=150
- t.MaxFPS 150
- p.NetShowCorrections 150