If you meant “GetController-HasAuthority” (as it is in my screenshot) instead of “GetActor->HasAuthority”:
- Let’s say we remove SwitchHasAuthority, so that “GetController->HasAuthority” would run both at the server and the client. BeginPlay first runs at the server, then runs at the client (at least I hope). We are first checking “GetController->HasAuthority” server-side, so the server would set the text correctly for each character. But now we are also letting each client to run the GetController->HasAuthority, which would evaluate to false since locally a client doesn’t have access to other player controllers but its own, setting now the text to “Client” for every character. So every client would see “Client” above the server character.
EDIT: This doesn’t actually happen. The “GetController->HasAuthority” just returns true if ROLE is ROLE_Authority. So it would return true for server spawned actors.
The reason it worked here was because “GetController->HasAuthority” was null for client characters (as stated by Amaresh below), so the branch would be false. I explained another solution in a new post. Sorry!
So yes, SwitchHasAuthority is internally the same as HasAuthority:
C++ HasAuthority:
FORCEINLINE_DEBUGGABLE bool AActor::HasAuthority() const
{
return (Role == ROLE_Authority);
}