Replication — server authoritative, eventual consistency, RPCs for commands
When people say "replication in Unreal", they really mean the built-in multiplayer stack under three strict rules: the server is the single source of truth, state is broadcast through replicated properties (eventual consistency), and discrete commands go through RPCs (point-to-point calls). It is not a symmetric P2P scheme, not "every client broadcasts to every other". It is one-directional: client → server (via Server RPC) → clients (via property replication and Multicast).
The classic mistake is putting gameplay logic on the client: "I clicked, I changed my HP, I told the server". In a server-authoritative model it works the other way around: the client asks via Server_DealDamage, the server validates (validation, anti-cheat), the server mutates the replicated variable, and clients find out about the change through OnRep_Health or simply by reading the new value on the next tick after the packet arrives.
The second recurring confusion is property replication vs RPCs. Different mechanisms with different semantics. A replicated property is state with eventual consistency: a freshly connecting player gets the current value; a dropped packet means the next update overwrites the old value and "things heal themselves". An RPC is a discrete event: "the shot happened", "play this effect"; a lost unreliable RPC is gone forever. The full map lives in the layers below.
Topic map
- Replication Basics — server-client model,
NetMode,RolevsRemoteRole,HasAuthority(). - Server Authority — why the server is the only source of truth, validation, cheat resistance.
- Replicated Properties —
UPROPERTY(Replicated),ReplicatedUsing,OnRep_*,COND_*conditions. - Property Registration —
GetLifetimeReplicatedProps,DOREPLIFETIME,DOREPLIFETIME_CONDITION. - bReplicates Flag —
AActor::bReplicates,bAlwaysRelevant,NetUpdateFrequency,NetCullDistance, relevancy. - RPCs —
Server/Client/NetMulticast, validation, routing, ownership. - RPC Types — Reliable vs Unreliable, ordering guarantees, payload limits.
- Property vs RPC — when to use which, state vs command, late-join.
Common traps
| Mistake | Consequence |
|---|---|
| Mutating a variable on the client and waiting for replication | Replication goes server → client only; client mutation is local and gets overwritten |
Forgetting bReplicates = true on the actor | UPROPERTY(Replicated) silently no-ops, RPCs do not route |
Forgetting GetLifetimeReplicatedProps + DOREPLIFETIME | Property is declared Replicated but never registered — nothing replicates |
Calling a Multicast RPC from a client | Doesn't reach other clients; multicast only fires from the server |
Calling a Server RPC on an actor without ownership | RPC is dropped; you need an owning connection |
Using Reliable Multicast for frequent events | Floods the reliable queue; exceeding the limit disconnects the client |
Putting a large TArray or string into an RPC | Over MaxRPCSize (~64 KB) → disconnect |
| Using RPCs to sync HP | HP is state — use a Replicated property; RPCs are for discrete events |
Sprinkling HasAuthority() checks where the code should run everywhere | Guards block client-side visual logic |
Hand-editing Role / RemoteRole | Driven by the engine; manual writes break replication |
| Testing only in PIE with one client | Many bugs (ownership, ordering) only appear in standalone / dedicated server |
Assuming OnRep is also called on the server | By default OnRep runs only on clients; on the server the value is set directly |
Interview relevance
Replication is a mandatory senior-level topic for any UE5 multiplayer interview. Checks:
- That the server is authority and clients are a reflection of its state.
- The difference between
RoleandRemoteRole(on the server myRoleisAuthority; on the client it is no longerAuthority). - How to declare and register a replicated property (two steps:
UPROPERTY+DOREPLIFETIME). - When to use
ReplicatedUsing=OnRep_Xand whereOnRep_Xruns. - The three RPC kinds and their directions:
Server(client→server),Client(server→owning client),NetMulticast(server→everyone). - Reliable vs Unreliable: delivery guarantees, ordering, why you can't spam reliables.
- When to replicate a property vs call an RPC: HP is a property, the shot is a multicast RPC, an action attempt is a server RPC.
- What
Relevancyis and why distant actors do not receive updates.
Common wrong answer: "Replication is syncing variables between clients — slap Replicated on a property and it broadcasts itself." Reality — the model is server-authoritative, the mutation happens on the server; without DOREPLIFETIME the Replicated flag does nothing; the direction is one-way; commands from client to server need a Server RPC, not an assignment.