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

Differentiating Server and Client Framework Roles

You will distinguish which gameplay classes exist on the server versus the client to ensure your logic functions correctly in a multiplayer environment.

In this lesson, you will learn how to determine which gameplay classes exist on the server, the client, or both to ensure your multiplayer logic stays synchronized.

The Authority Hierarchy

In Unreal Engine’s multiplayer architecture, the Server acts as the single source of truth. It holds the "authoritative" version of the world, while Clients are merely observers that receive updates from the server. Understanding which classes live where is the key to preventing bugs like "ghosting" (where a player sees an item, but the server thinks it’s gone).

Where the Classes Live

  • GameMode: Exists only on the Server. Clients never see it. This is why you should never put code in GameMode that needs to run on a player's machine (like spawning UI).
  • GameState: Exists on both the Server and all Clients. It is replicated, meaning the server sends updates to clients so everyone knows the current score or match duration.
  • PlayerController: Exists on the Server and the owning Client only. The server has a version for every player, but a specific client only has access to its own controller.
  • Pawn/Character: Exists on all machines. These are the visual representations of players, so they must be replicated so that every player can see everyone else moving around.

Practical Logic Check

If you are writing logic to handle a player picking up an item, you must check where you are running that code. If you try to update the GameMode from a client, your code will fail because that class doesn't exist there.

// Example: Checking for authority
if (HasAuthority()) 
{
    // This logic only runs on the Server.
    // Safe to modify the GameMode or persistent state here.
}
else 
{
    // This logic runs on the Client.
    // Use this for local effects like sounds or UI updates.
}

By keeping your logic separated, you ensure that the server remains the master of the game state while clients provide a smooth, responsive experience for the player.

Key Takeaway: The Server dictates the rules via classes like GameMode, while Clients and Servers synchronize through replicated classes like GameState and Pawns.