Skip to main content

Resource

Replication

Replication conditions, DOREPLIFETIME macros, RPCs, push model, net roles, relevancy, and custom serialization. The networking reference you keep going back to.

Replication conditions

Conditions control when a property replicates. Pass them to DOREPLIFETIME_CONDITION or set them in FDoRepLifetimeParams. Every condition is evaluated per-connection.

COND_None

No condition. Property replicates every time it changes.

COND_InitialOnly

Only replicates on the initial bunch. After first replication, never updates.

COND_OwnerOnly

Only replicates to the actor's owner connection.

COND_SkipOwner

Replicates to every connection except the owner.

COND_SimulatedOnly

Only replicates to simulated proxies (not the autonomous proxy).

COND_AutonomousOnly

Only replicates to the autonomous proxy (the owning client).

COND_SimulatedOrPhysics

Replicates to simulated proxies or actors with bRepPhysics enabled.

COND_InitialOrOwner

Replicates on the initial bunch or to the owner connection.

COND_Custom

No built-in condition. Toggle replication on or off at runtime using DOREPCUSTOMCONDITION_SETACTIVE_FAST.

COND_ReplayOrOwner

Replicates to the replay connection or the owner.

COND_ReplayOnly

Only replicates to the replay connection.

COND_SimulatedOnlyNoReplay

Simulated proxies only, excluding replay connections.

COND_SimulatedOrPhysicsNoReplay

Simulated or physics proxies, excluding replay connections.

COND_SkipReplay

Replicates to all connections except replay.

COND_Dynamic

Condition is set at runtime. Defaults to always replicate until changed.

COND_Never

Property never replicates.

COND_NetGroup

Subobject replicates to connections in the same net group. Not valid for properties.

RepNotify conditions

Controls when the OnRep callback fires. Set via DOREPLIFETIME_CONDITION_NOTIFY or the RepNotifyCondition field in FDoRepLifetimeParams.

REPNOTIFY_OnChanged

Only fires if the received value differs from the local value. This is the default.

REPNOTIFY_Always

Fires every time the property is received from the server, even if the value hasn't changed.

DOREPLIFETIME macros

All of these go inside GetLifetimeReplicatedProps. The _FAST variants use compile-time generated enums for faster property lookup.

DOREPLIFETIME(Class, Prop)

Replicate with no conditions. The simplest form.

DOREPLIFETIME_CONDITION(Class, Prop, Cond)

Replicate with a specific condition (COND_OwnerOnly, etc).

DOREPLIFETIME_CONDITION_NOTIFY(Class, Prop, Cond, NotifyCond)

Replicate with condition and RepNotify behavior.

DOREPLIFETIME_WITH_PARAMS(Class, Prop, Params)

Full control via FDoRepLifetimeParams struct.

DOREPLIFETIME_WITH_PARAMS_FAST(Class, Prop, Params)

Optimized version using compile-time enums.

DISABLE_REPLICATED_PROPERTY(Class, Prop)

Stop replicating a property inherited from a parent class.

DISABLE_REPLICATED_PRIVATE_PROPERTY(Class, Prop)

Same as above but for private inherited properties.

DISABLE_ALL_CLASS_REPLICATED_PROPERTIES(Class, SuperBehavior)

Disable all replicated properties of a class.

RESET_REPLIFETIME(Class, Prop)

Reset inherited property replication to COND_None.

RESET_REPLIFETIME_CONDITION(Class, Prop, Cond)

Change the replication condition of an inherited property.

FDoRepLifetimeParams

The params struct gives full control over replication behavior. Pass it to DOREPLIFETIME_WITH_PARAMS.

Field
Type
Default
ConditionELifetimeConditionCOND_None
RepNotifyConditionELifetimeRepNotifyConditionREPNOTIFY_OnChanged
bIsPushBasedboolfalse
CreateAndRegisterReplicationFragmentFunctionUE::Net::CreateAndRegisterReplicationFragmentFuncnullptr

RPCs

Remote Procedure Calls execute a function on a different machine. The specifier determines direction. Reliable or Unreliable determines delivery guarantee.

ServerClient → ServerServer only

Requires actor ownership. Pair with Reliable or Unreliable.

ClientServer → ClientOwning client

Only the client that owns the actor receives it.

NetMulticastServer → AllServer + all clients

Executes locally on server and replicates to every client.

Reliable

Guaranteed delivery via reliable channel. Queue can overflow if overused.

Unreliable

Best-effort delivery. May be dropped under congestion. Use for frequent calls.

WithValidation

Requires _Validate function. Return false to reject RPC and disconnect client.

Implementation pattern

Every RPC requires a _Implementation function. The engine generates a thunk that routes the call over the network. WithValidation additionally requires a _Validate function that returns bool.

Dynamic and custom conditions

COND_Custom lets you toggle replication on/off at runtime. COND_Dynamic lets you change the condition itself at runtime.

DOREPCUSTOMCONDITION_SETACTIVE_FAST(Class, Prop, bActive)

Toggle a COND_Custom property on or off at runtime.

DOREPDYNAMICCONDITION_INITCONDITION_FAST(Class, Prop, Cond)

Set initial condition for a COND_Dynamic property.

DOREPDYNAMICCONDITION_SETCONDITION_FAST(Class, Prop, Cond)

Change a COND_Dynamic property's condition at runtime.

DOREPLIFETIME_ACTIVE_OVERRIDE_FAST(Class, Prop, bActive)

Override whether a property is active for replication.

Push model replication

By default, the engine polls every replicated property every frame to check if it changed. Push model skips the polling — you tell the engine when a property is dirty. This saves CPU on actors with many replicated properties that rarely change.

  • 01Set bIsPushBased = true in FDoRepLifetimeParams when registering the property.
  • 02Call MARK_PROPERTY_DIRTY_FROM_NAME or UNetPushModelHelpers::MarkPropertyDirty whenever you change the value.
  • 03If you forget to mark dirty, the property won't replicate until the next full comparison pass.

Quantized vector types

Use these instead of raw FVector for replicated properties to reduce bandwidth. Each trades precision for smaller packet size.

Type
Precision
Bits Per Component
FVector_NetQuantize0 decimals20 bits
FVector_NetQuantize101 decimal24 bits
FVector_NetQuantize1002 decimals30 bits
FVector_NetQuantizeNormalNormalized (-1 to 1)16 bits

Net roles

Every actor has a local role and a remote role. Check GetLocalRole() to know what this machine is responsible for.

ROLE_Authority

This machine owns the authoritative state. On the server for replicated actors.

ROLE_AutonomousProxy

Client-controlled proxy. The owning client predicts movement and sends input to the server.

ROLE_SimulatedProxy

Server-controlled proxy on a non-owning client. State is received from the server and interpolated.

ROLE_None

No role assigned. The actor is not replicated or has not been initialized for networking.

Actor replication properties

These properties on AActor control how the actor behaves in a networked context.

Property
Type
Purpose
bReplicatesboolMaster flag. If false, nothing on this actor replicates.
NetUpdateFrequencyfloatHow often (Hz) the actor considers replicating. Default is 100.
MinNetUpdateFrequencyfloatFloor for adaptive replication frequency.
NetPriorityfloatRelative priority for bandwidth allocation. Higher = more bandwidth.
NetCullDistanceSquaredfloatSquared distance beyond which the actor is not relevant to a connection.

Relevancy

An actor is only replicated to connections it's relevant to. Override IsNetRelevantFor for custom logic.

  • 01bAlwaysRelevant — actor replicates to every connection regardless of distance.
  • 02bOnlyRelevantToOwner — actor only replicates to its owning connection.
  • 03bNetUseOwnerRelevancy — defer relevancy check to the owner actor.
  • 04NetCullDistanceSquared — distance-based relevancy culling.
  • 05IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation) — override for custom relevancy logic.

Custom serialization

For structs that need tighter control over what bytes go over the wire.

NetSerialize

Full custom serialization for a USTRUCT. Implement on the struct and set WithNetSerializer in TStructOpsTypeTraits.

NetDeltaSerialize

Delta compression. Only sends what changed since the last acknowledged state. Used by FastArraySerializer.

SafeNetSerializeTArray_Default<MaxNum>

Serialize a TArray with a max element count to prevent malicious allocation.

SafeNetSerializeTArray_WithNetSerialize<MaxNum>

Same but calls NetSerialize on each element instead of the << operator.

SerializeOptionalValue

Serialize a value only if it differs from the default. Costs 1 bit when value matches default.

Anti-patterns

Marking Tick as a Reliable RPCReliable RPCs queue up. High-frequency calls overflow the reliable buffer and disconnect the client.
Replicating everything with COND_NoneBandwidth is limited. Use COND_OwnerOnly for owner-specific data and COND_InitialOnly for data that doesn't change.
Forgetting GetLifetimeReplicatedPropsMarking a property Replicated without registering it in GetLifetimeReplicatedProps does nothing silently.
Using Reliable NetMulticast for cosmetic effectsReliable multicast scales with player count. An explosion seen by 100 players queues 100 reliable messages. Use Unreliable.
Modifying replicated state on clientsClient changes are overwritten on the next server update. Predict locally but let the server be authoritative.
Using push model without marking dirtyThe property won't replicate until the next full comparison pass. Every setter must call the dirty macro.

Unreal Directive is free and ad-free.

If it saved you time, you can help keep it that way.

Donate