I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX
Legacy:Role
Role is a concept in replication. Actors have two properties to define their role on server and client in network games: Role
and RemoteRole
. Role always tells us (and the engine :)) about the actor's local role while RemoteRole tells about the actor's role on the other side of the network. When an actor is replicated to a client, its Role and RemoteRole properties are swapped there, so the serverside Role value becomes the clientside RemoteRole value and vice versa. When we talk about an actor's Role or RemoteRole on this page we always mean "as viewed from the local machine."
- All actors existing on the server have Role == ROLE_Authority there, while their RemoteRole can be either ROLE_None, ROLE_DumbProxy, ROLE_SimulatedProxy or ROLE_AutonomousProxy.
- On the clients the replicated actors have their Role and RemoteRole swapped, i.e. RemoteRole == ROLE_Authority and Role is any of the other values according to the Actor's RemoteRole on the server.
- Client-side actors (i.e. actors that weren't replicated, but spawned on the client) have
Role == ROLE_Authority
on the network client. These actors only exist on the client they were spawned on. They can't be replicated to any other client or the server.
What do the different net roles mean?[edit]
The net roles are defined in the Actor class, as the enum ENetRole (see Actor/Enums for others).
- ROLE_None
- In
RemoteRole
This means that none of the actor's attributes or functions will be replicated at all. Examples for this kind of actors are the GameInfo, Mutators and GameRules as well as some explosion effects and decals in UT. InRole
it is contradictory, as it implies the actor does not exist on the machine this script is executing on.
Note: is is perfectly possible to instantiate an Actor on multiple network machines by using simulated functions. However these will not be tied together by replication and the client copies will not function as proxies for the server copy. For instance, destroying the actor on the server will not destroy any corresponding actor on the client (and vice-versa).
- ROLE_DumbProxy
- The actor is replicated, but most (if not all) of its logic stays on the server. Theoretically the actor may execute simulated functions and simulated state code, but this is rarely used. Usually clientside behavior is purely a result of replicating variables.
If you see this inRole
it means we are looking at the proxy instance, not the copy that was authoratively spawned.
- ROLE_SimulatedProxy
- The actor is replicated and may execute simulated functions and simulated state code on the remote side. Often this kind of actor simulates its behavior based on initially replicated properties without (much) further "help" from the server.
- ROLE_AutonomousProxy
- The client has autonomous control over the actor replicated to it. The actor is not restricted to simulated functions and can execute non-simulated functions and state code as well. For other clients these actors appear as regular simulated proxies.
This (Remote)Role is usually used for the player actor (PlayerPawn in UE1, PlayerController in UE2) and important actors controlled by it, like the GuidedWarshell (the guided redeemer warhead) in UT or all kind of Pawns in UT2003 (including UT2004 Vehicles).
- ROLE_Authority
- All functions can be executed. This must appear in
Role
on the machine the actor was spawned on, and must appear in eitherRole
orRemoteRole
(but not both) for every actor. In standalone games all Actors haveRole == ROLE_Authority
. In net play nearly all Actors have thisRole
on the server. The exception is actors that cannot influence other players, such as Karma ragdolls. Never manually set the RemoteRole on the authorative version of an actor or the Role on a replicated version of the actor to this value.
When your script sees RemoteRole == ROLE_Authority
it means it is executing on the proxy version of the Actor. Usually it's more useful to check the value of Role
though.
Possible Combinations of Roles[edit]
Server | Client | Owner Client | Example |
ROLE_Authority | ROLE_SimulatedProxy | ROLE_SimulatedProxy | Projectiles, most ReplicationInfos, a Pawn's Inventory |
ROLE_Authority | ROLE_SimulatedProxy | ROLE_AutonomousProxy | UT: PlayerPawns, GuidedRedeemer UT200x: Pawns currently possessed by a client player (includes Vehicles and the guided RedeemerWarhead) |
ROLE_Authority | ROLE_DumbProxy | ROLE_DumbProxy | UT200x Pickups, certain effects that need to be replicated but don't need to simulate any behavior |
ROLE_Authority | ROLE_Authority | ROLE_Authority | XPawn ragdolls (see note below) |
It's not unusual that an actor's clientside role changes. The last example is a special case which happens only when the server sets bTearOff=True on a simulated proxy after the actor has been replicated. The server and client versions of the actor become completely independent and nothing is replicated between them anymore. In UT pickups often change between simulated and dumb proxies when they are picked up or dropped.
Related Topics[edit]
- Replication
- Netcode Idioms – useful code to pick out different types of machine
- NetMode – tells you what type of game is running: server, client, etc.
- Simulated Function
- Replicated Function