Networking: understanding SwitchHasAuthority

Hi, everyone.
I’m kinda trying to dig in into UE4 networking and I came across the SwitchHasAuthority node which is supposed to tell you whether you are a client or a server. I quickly made a simple test inside the Character Blueprint:

My InputActionCast is bound to Left Mouse. So, when I pressed Left Mouse inside the server instance, I got the message “Server: SERVER” popping up on BOTH server and client instances. Doing the same but from client instance got me “Client: CLIENT” appearing on both client and server instances.

What I really expected to happen was the message “Server: SERVER” to appear ONLY on server instance and “Client: CLIENT” only on client instance. Am I missing something here?

I did multiple networking things but the print string after switch has authority confuses me as well. I asume that print string always gets printed on both, server and client. and the string “Server” or “Client” infront of the message indicates on which machine it’s running. I would rather test this with spawning an actor that is not replicated.

That could be just the way printString works. A better visualizer would be to use a widget.

I’ve created one to demonstrate the switch has authority.

This pdf goes over all the aspects of online multiplayer. I had a lot of problems understanding how it worked as well, I highly recommend reading it.

Wow, thank you guys for clarifying this thing to me. Looks like printString really screwed me up. I didn’t expect that function to work that way.

Will definitely be checking out that pdf. Thanks a lot.

youre welcome. the one with the widget is an even better solution. didn’t think of that, It was kind of late for me :wink: