| Home Page | Recent Changes | Preferences

Replication Block

The replication block specifies which of the variables and/or functions declared in a class are replicated. It is optional and only variables and functions mentioned in this block are actually replicated. Variables of a class that aren't mentined are initialized with their default values on clients.

Syntax

 replication
 {
   reliable/unreliable if ( replication condition )
     variables or functions;
 }

The replication condition is a boolean expression which tells the engine when something should be replicated to a remote machine. You can call functions here, but it really isn't recommended because it will slow things down and can cause undesireable results.

The variables or functions are a comma-seperated list of variables or functions that must be declared in this class for the first time. You can't (re)define replication conditions for a superclass's variables or functions.

Reliable/unreliable tells how the replication behaves in case of packetloss. Reliable replication is guaranteed to reach the remote machine even with packetloss, while unreliable replication isn't.

Within the replication block there can be multiple lists of variables and functions, each with its own reliability and replication condition. However, each variable and function may appear in only one of the lists.

Examples

Let's have a look at a typical replication block:

replication
{
  reliable if ( Role == ROLE_Authority )
    RemainingMinute, bStopCountDown, GameEndedComments,
    NumPlayers;

  reliable if ( bNetInitial && (Role==ROLE_Authority) )
    GameName, GameClass, bTeamGame, ServerName, ShortName, AdminName,
    AdminEmail, Region, MOTDLine1, MOTDLine2, 
    MOTDLine3, MOTDLine4,RemainingTime, ElapsedTime;
}

This one defines two groups of replicated variables in the GameReplicationInfo (UT) class. Here you can already see the most important part of a replication condition, the actor's Role. Either the Role or the RemoteRole is always present in a replication condition.

Variables can only be replicated from the authorative version of an actor (i.e. from the server) to the clients. These replication conditions can become quite complex if it helps saving bandwidth, as this example from the Actor (UT2003) class shows:

  unreliable if ( (!bSkipActorPropertyReplication || bNetInitial) && bReplicateMovement
      && (((RemoteRole == ROLE_AutonomousProxy) && bNetInitial)
          || ((RemoteRole == ROLE_SimulatedProxy) && (bNetInitial || bUpdateSimulatedPosition)
              && ((Base == None) || Base.bWorldGeometry))
          || ((RemoteRole == ROLE_DumbProxy) && ((Base == None) || Base.bWorldGeometry))) )
    Location;

So whether the location of an actor is replicated depends on the actor's RemoteRole and whether bReplicateMovement is True. The bSkipActorPropertyReplication can be used to cut down replication of actor class variables to only the initial replication.

Useful Replication Properties

Variables only valid during replication

bClientDemoNetFunc
True if we're client-side demo recording and this call originated from the remote.
bClientDemoRecording
This machine is currently recording a clientside demo.
bDemoRecording
This machine is currently recording a demo.
bNetInitial
True during the first time all variables are replicated for this actor.
bNetOwner
True when the replication target is this actor's Owner.

Only UT

bNetFeel
Player collides with/feels it in network play.
bNetHear
Player hears it in network play.
bNetSee
Player sees it in network play.
bSimulatedPawn
True if this is a Pawn (UT) and simulated proxy.

Only UT2003

bDemoOwner
Demo recording driver owns this actor.
bNetDirty
True when a property was changes since the last time it was replicated.
bNetRelevant
Actor is currently relevant. Only valid server side and only when replicating variables.
bRepClientDemo
The remote machine is currently recording a demo.
Level.ReplicationViewer
during replication, set to the playercontroller to which actors are currently being replicated
Level.ReplicationViewTarget
during replication, set to the viewtarget to which actors are currently being replicated

Other Useful Variables

In UT

bClientAnim
If True, AmbientSound and animations are replicated also to the owning client.

In UT2003

These properties are used in the Actor class replication block.

bNoRepMesh
Don't replicate the Mesh.
bReplicateAnimations
Whether SimAnim should be replicated.
bReplicateInstigator
Whether the Instigator should be replicated.
bReplicateMovement
Whether properties relevant for movement like Location, Rotation, Velocity, etc. should be replicated. Unlike bSkipActorPropertyReplication this also affects the initial replication.
bSkipActorPropertyReplication
Used by ReplicationInfo classes that don't need to know all the Actor class properties on the clients. When set to True only the initial replication replicates the Actor class properties.
bUpdateSimulatedPosition
Whether the actor's Location, Rotation and Velocity should be updated for Simulated Proxies.

Related Topics


Category Tutorial

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In