Download

Role_Authority explanation needed.

So i have never really understood ROLE_Authority i normally just use the one that works, i was wondering if someone could explain the three ways this could be used. I have read about them via documents and other posts but i dont understand them.

Role > ROLE_Authority
Role == ROLE_Authority
Role < ROLE_Authority

Those are the three i dont understand

Roles are something that exists on Actor classes and anything that derives from it (ex. Pawn, Character, etc). ROLE_Authority means that the actor exists on the host/server computer. So all players and actors would be ROLE_Authority on that computer. ROLE_AutonomousProxy is the actor/pawn that is on the client computer AND that you are in control of. So there’s usually 1 AutonomousProxy’s for every client computer. ROLE_SimulatedProxy is actors/pawns that exist ONLY on the client computers where the client is NOT in control of. So on a client computer, if the player controls a pawn, that would be an autonomous proxy (has player controller). The one that he doesn’t control (so another computer controls) would be a simulated proxy on his/her computer (no player controller, information comes from server).



enum ENetRole
{
    ROLE_None,
    ROLE_SimulatedProxy,
    ROLE_AutonomousProxy,
    ROLE_Authority,
    ROLE_MAX,
}


Knowing that and the order of the ROLE enums, it makes sense what those code you listed out mean. Role > ROLE_Authority doesn’t make sense actually. Role == ROLE_Authority is check if the actor is on the server. Its the same as HasAuthority pretty much. Role < ROLE_Authority is checking if the role of the actor is either a Simulated Proxy or Autonomous Proxy. You would use this to do something for all client computers (so like spawn a particle for all of them).

Oh right thanks that clears a lot up.