Hi! I am learning Networking for a Multiplayer Project and am experiencing issues while trying to run test to determine which running Engine Instance has Authority.
According to UE documentation Doc, we can retrieve Actor Role and Remote Role using GetLocalRole() & GetRemoteRole(), however when I am trying to simply print a message, using GEngine, in C++, both Server Window and Client Window display the same message.
Additionally, whenever I call SwitchHasAuthority from Blueprint to setup my UMaterialInstance on the Server Characters and Clients both work fine and apply the proper Material to it.
Can someone explain why Role Authority doesn’t seem to work in c++?
Thanks!
Not a direct answer but some other avenues to look at…
ROLE_Authority alone is not good enough to determine server/client relationship. There are other pieces to the puzzle like GetNetMode() which will explicitly tell you if it’s the client or server. It might be worth looking at exactly what HasAuthority from Actor.cpp is doing to determine that. I don’t have it in front of me or I’d check myself.
I believe I encountered something similar recently and had to dive down this rabbit hole. I’ll attempt to dig it up and post here. I remember feeling like “huh?!” once I figured out what was going on as it wasn’t entirely intuitive but was just my mis-understanding.
1 Like