Course contentsShow
← Unreal Engine Game Development
Lesson 130 of 8802. The Gameplay FrameworkFree lesson

Debugging Distributed Gameplay States

You will use Unreal's network profiler and visual debuggers to identify and fix synchronization issues between server and client game states.

In this lesson, you will learn how to use Unreal’s built-in networking tools to identify and fix "desyncs"—those moments when your server thinks one thing is happening, but your client shows something else.

Why Gameplay States Get Out of Sync

When you develop for multiplayer, the server is the ultimate source of truth. Sometimes, a variable—like a player's CurrentScore or a match state—replicates incorrectly due to race conditions or skipped updates. Instead of guessing, we use the Network Profiler and Visual Log to see exactly what the engine is sending across the wire.

Using the Network Profiler

The Network Profiler is your microscope for bandwidth and replication. To use it, you must launch your game with the command line argument -networkprofiler=true. After playing your session, the profiler generates a file in your project’s Saved/Profiling folder. When you open this in the Unreal Editor (via Window > Developer Tools > Network Profiler), you can see a timeline of every RPC and variable replication event. If you notice a spike in data or a missing state update, you’ve found the culprit.

Visual Debugging with "Net Debug"

While the profiler handles data, the Visual Logger helps you see the physical manifestation of state. By running the console command VisLog during gameplay, you can record snapshots of actors. If your GameState says the match is in the "PostMatch" phase but your client remains in "InProgress," the Visual Logger allows you to step back through frames to identify exactly when the client failed to receive the OnRep_MatchState function call.

You can also use the console command p.NetShowProperty [PropertyName] to monitor a variable's value changes in real-time on the screen. This is the fastest way to verify if a variable is actually being replicated to your client:

// Check if the variable is correctly marked for replication
UPROPERTY(ReplicatedUsing=OnRep_GameState)
TEnumAsByte<EMatchState> CurrentMatchState;

If the OnRep function isn't firing on the client, you know the issue isn't your logic—it's your replication setup.

Key Takeaway: Always verify your state by inspecting the network traffic rather than assuming the code is running, using the Network Profiler to spot data gaps and the Visual Logger to track state transitions over time.