About Role and RemoteRole, why swap wether run in Engine or build?

Hi!

For someone coming from unet I dont quite understant why there are 2 roles for each instance; Role and RemoteRole. I do understand that they are swappable wether we are the server or client running instance; my role is always Role and the other’s is RemoteRole, what I dont understand is WHY do we care about the other’s role? I mean, its not like we could run code for them, right?

Quote ue4 doc:

Role/RemoteRole Reversal

Role and RemoteRole could be reversed
depending on who is inspecting these
values. For example, if on the server
you have this configuration:

Role == ROLE_Authority
RemoteRole == ROLE_SimulatedProxy 

Then the client would see it as this:

Role == ROLE_SimulatedProxy
RemoteRole == ROLE_Authority 

What I further dont understand is why the Roles swap wether we are running in the Editor or a Build/Standalone.
For instance, in Build/Standalone play i’ve got some code that doesnt execute if I test (Role== Role_AutonomousProxy) but does if it is (RemoteRole== Role_AutoProx). Inversely, the same code doesnt run in Editor if I have (RemoteRole== Role_AutonomousProxy) but does if it is (Role== Role_AutoProx). Notice that Role & RemoteRole are swapped.

For my code to run as expected in both Editor and Build I must test for (GetRemoteRole() == ROLE_AutonomousProxy || Role == ROLE_AutonomousProxy), which to me doesn’t make any sense? Why have 2 different means of verifying the same thing wether it is build or editor?

For context: this code is run in the Player’s owned pawn, spawned by Server with the Player’s PlayerController as Owner. This condition decides wether or not I enable a CombatSystem module for the Player to run locally. In which case only the controlling player needs it and the Server/Clients dont. Also, I dont it does much, but “Run Dedicated Server” option is checked.

I would greatly appreciate any clarification on this, thanks!

Imagine that you got some specific movement of 2 objects controlled by players and between net updates you want to interpolate values to make it smooth.
You spawn both objects on the listen server, so when you check the role on them you will get authority.
When you’ll check remote role you will get one autonomous proxy and one simulated proxy.
Now you know that you only want to smooth simulated proxy becouse you are in controll of the other one and you don’t need to smooth the movement here becouse you get the updates every tick.