In this lesson, you will learn how to leverage Unreal Engine’s built-in visualization tools to identify the exact moment a client’s predicted movement diverges from the server’s authoritative state.
When a client predicts movement, it moves instantly while the server processes the input slightly later. If the server calculates a different position—perhaps due to a collision or logic error—a "correction" occurs, causing a visual snap. To debug this, we use the p.NetShowCorrections console command.
Visualizing Discrepancies
When you enable p.NetShowCorrections 1 in the console, the engine draws a visual representation of the mismatch. The server's authoritative position will appear as a red capsule, while your client-side prediction remains at your current location. If these capsules diverge, you know your CharacterMovementComponent has detected an error.
Analyzing the Mismatch
Once the correction is triggered, look for the following logs in your Output Log (filtered by LogNetMovement):
- Client Error: The vector difference between your predicted position and the server’s authoritative position.
- Timestamp: The time at which the move occurred, helping you correlate the glitch with specific input frames.
If you are implementing custom movement logic, you must ensure your logic is deterministic. If your logic produces different results on the client versus the server, the engine will force a correction. You can inspect these discrepancies by setting a breakpoint in ServerMoveHandleClientError inside the engine source code to catch the exact moment the server overrides your client state.
Best Practice
Always compare your logic against the standard CharacterMovementComponent flow. If you find consistent, large discrepancies, check for non-deterministic variables (like using FMath::FRand without a synced seed or uninitialized variables) that might influence the movement calculation differently on two machines.
Key Takeaway: Use p.NetShowCorrections 1 to visually verify if your movement logic is deterministic; if the red server-capsule drifts from your client-player, your prediction logic is failing to match the server’s authoritative calculation.