In this lesson, you will learn how to distinguish between the server's authoritative game state and the specific permissions granted to individual clients through actor ownership.
In Unreal Engine’s client-server model, the server is the single source of truth. Authority refers to the machine that holds the "master copy" of an actor’s properties and logic. By default, only the server possesses ROLE_Authority. If a client attempts to change a variable (like Health or Ammo), that change will not persist or replicate unless it is handled by the server.
The Role of Ownership
While the server holds authority, Ownership defines which specific client (if any) "owns" an actor. An actor is typically owned by a PlayerController or a Pawn. Ownership is the bridge that grants a client permission to perform actions that would otherwise be rejected or ignored, such as sending an RPC (Remote Procedure Call) marked as Server.
Without a clear ownership relationship—specifically, if a client is not the owner of an actor—they cannot trigger Server RPCs on that actor. This serves as a critical security layer: if a client doesn't own the character, they shouldn't be allowed to tell the server to execute logic for that character.
Identifying Authority and Ownership
You can check these states in your C++ logic to ensure code only runs where it is safe:
// Check if the machine running this code has the final say
if (HasAuthority()) {
// Modify game state variables here
}
// Check if this specific client owns the actor (e.g., local player's character)
if (IsLocallyControlled()) {
// Execute logic that requires input from this specific player
}
The distinction is subtle but vital: Authority determines who changes the data (the server), while Ownership determines who has the right to initiate requests for those changes (the player). By strictly controlling these two concepts, you prevent unauthorized clients from spoofing gameplay events, ensuring that your state remains synchronized and secure across the network.
Key Takeaway: The server holds total authority over game state, while ownership dictates which specific client is permitted to interact with or command a particular actor.