Always snap to grid

Difference between revisions of "Legacy:Role"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m (*Inserted apostrophe in 'actors')
m (removed non-existing category)
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
* '''Client-side actors''' (i.e. actors that weren't replicated, but spawned on the client) have <code>Role == ROLE_Authority</code> ''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.
 
* '''Client-side actors''' (i.e. actors that weren't replicated, but spawned on the client) have <code>Role == ROLE_Authority</code> ''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? ==
+
==What do the different net roles mean?==
  
 
The net roles are defined in the Actor class, as the enum ENetRole (see [[Legacy:Actor/Enums|Actor/Enums]] for others).
 
The net roles are defined in the Actor class, as the enum ENetRole (see [[Legacy:Actor/Enums|Actor/Enums]] for others).
Line 11: Line 11:
 
; ROLE_None : In <code>RemoteRole</code> This means that none of the actor's attributes or functions will be replicated at all.  Examples for this kind of actors are the [[Legacy:GameInfo|GameInfo]], [[Legacy:Mutator|Mutator]]s and [[Legacy:GameRules|GameRules]] as well as some explosion effects and [[Legacy:Decal|decal]]s in UT.  In <code>Role</code> it is contradictory, as it implies the actor does not exist on the machine this script is executing on. <br />'''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_None : In <code>RemoteRole</code> This means that none of the actor's attributes or functions will be replicated at all.  Examples for this kind of actors are the [[Legacy:GameInfo|GameInfo]], [[Legacy:Mutator|Mutator]]s and [[Legacy:GameRules|GameRules]] as well as some explosion effects and [[Legacy:Decal|decal]]s in UT.  In <code>Role</code> it is contradictory, as it implies the actor does not exist on the machine this script is executing on. <br />'''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 can't execute any functions on the remote side. It will update when variables are replicated to it but will not attempt to interpolate. If you see this in <code>Role</code> it means we are looking at the proxy, not the copy that was authoritatively spawned.
+
; ROLE_DumbProxy : The actor is replicated, but most (if not all) of its logic stays on the server. Theoretically the actor may execute [[Legacy:Simulated Function|simulated function]]s and simulated state code, but this is rarely used. Usually clientside behavior is purely a result of replicating variables.<br />If you see this in <code>Role</code> 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 [[Legacy:Simulated Function|simulated function]]s 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_SimulatedProxy : The actor is replicated and may execute [[Legacy:Simulated Function|simulated function]]s 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 : Autonomous proxies come with some more magic built-in. :) They are basically simulated proxies, but may execute simulated and non-simulated functions on the client owning/controlling this actor (only on that client!).<br />In UT only [[Legacy:PlayerPawn|PlayerPawn]]s are autonomous proxies, in UT2003 only [[Legacy:PlayerController|PlayerController]]s are. Every other client sees them as a regular simulated proxy. Player-controlled actors, such as the guided redeemer missile (GuidedWarshell in UT or RedeemerWarhead in UT2003) are autonomous proxies on the controlling player's client, too.<br />'''Sweavo:''' more clarification needed here
+
; 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.<br />This (Remote)Role is usually used for the player actor ([[Legacy:PlayerPawn|PlayerPawn]] in UE1, [[Legacy:PlayerController|PlayerController]] in UE2) and important actors controlled by it, like the [[Legacy:GuidedWarshell|GuidedWarshell]] (the guided redeemer warhead) in [[Legacy:UT|UT]] or all kind of [[Legacy:Pawn|Pawn]]s in [[Legacy:UT2003|UT2003]] (including [[Legacy:UT2004|UT2004]] [[Legacy:Vehicle|Vehicle]]s).
  
 
; ROLE_Authority : All functions can be executed.  This must appear in <code>Role</code> on the machine the actor was spawned on, and must appear in either <code>Role</code> or <code>RemoteRole</code> (but not both) for every actor.  In standalone games all Actors have <code>Role == ROLE_Authority</code>.  In net play nearly all Actors have this <code>Role</code> on the server.  The exception is actors that cannot influence other players, such as [[Legacy:Karma Ragdoll|Karma ragdoll]]s.  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.
 
; ROLE_Authority : All functions can be executed.  This must appear in <code>Role</code> on the machine the actor was spawned on, and must appear in either <code>Role</code> or <code>RemoteRole</code> (but not both) for every actor.  In standalone games all Actors have <code>Role == ROLE_Authority</code>.  In net play nearly all Actors have this <code>Role</code> on the server.  The exception is actors that cannot influence other players, such as [[Legacy:Karma Ragdoll|Karma ragdoll]]s.  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.
Line 44: Line 44:
 
|ROLE_DumbProxy
 
|ROLE_DumbProxy
 
|ROLE_DumbProxy
 
|ROLE_DumbProxy
|UT200x [[Legacy:Pickup|Pickup]]s, certain effects that need to be replicated but don't have to simulate any behavior
+
|UT200x [[Legacy:Pickup|Pickup]]s, certain effects that need to be replicated but don't need to simulate any behavior
 
|-
 
|-
 
|ROLE_Authority
 
|ROLE_Authority
Line 52: Line 52:
 
|}
 
|}
  
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 independant and nothing is replicated between them anymore. In UT pickups often change between simulated and dumb proxies.
+
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 ==
+
==Related Topics==
 
* [[Legacy:Replication|Replication]]
 
* [[Legacy:Replication|Replication]]
 
* [[Legacy:Netcode Idioms|Netcode Idioms]] &ndash; useful code to pick out different types of machine
 
* [[Legacy:Netcode Idioms|Netcode Idioms]] &ndash; useful code to pick out different types of machine
Line 62: Line 62:
  
 
[[Category:Legacy Enum|{{PAGENAME}}]]
 
[[Category:Legacy Enum|{{PAGENAME}}]]
[[Category:Legacy Replication|{{PAGENAME}}]]
 

Latest revision as of 05:28, 20 May 2008

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. In Role 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 in Role 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 either Role or RemoteRole (but not both) for every actor. In standalone games all Actors have Role == ROLE_Authority. In net play nearly all Actors have this Role 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]