What’s the relationship and difference between Role and NetMode in Online Game ? When and Where should I use NetMode? When and Where should I use Role?
NetMode is global, and essentially determines what part of the Server-Client architecture the Net Connection is, so it’s either Standalone, Server or Client. Almost all of the time, NetMode is the same regardless of where you call it from.
Role is different. It determines what the local users control is over that instance of the actor. There are ‘Role’ and ‘RemoteRole’ values, but ‘Role’ is the one you use most often.
ROLE_Authority - Means that the local game instance has full authority over that actor. If an actor is spawned on the Server and replicated to clients, then the server has Authority role, and the clients are SimulatedProxy. If an actor is spawned on a client and/or only exists locally, the client role is Authority. In a Standalone game, all actors would have ROLE_Authority.
ROLE_SimulatedProxy - On a Client, this usually means an actor that is owned by the Server and replicated from it.
ROLE_AutonomousProxy - On a Client, this usually means an actor that is possessed by that same client (e.g a character) - but is ‘owned’ by the Server and replicated from it. Characters controlled by other clients would have the ROLE_SimulatedProxy.
Role is generally more useful than the NetMode, since it governs what can/can’t be done locally. Sometimes (but rarely), you need both.