Switch Has Authority Returning Authority For Client

Hello,

I set up a simple blueprint that should print “auth” or “rem” depending on the result of a Switch Has Authority call, and it is printing “auth” even on client side… I am testing this using the in-editor network simulation.

Blueprint and results below. Any ideas as to why this might happen?

Hi Parrot Wing,

This will depend on how you’re spawning your HUD. Authority is a per-actor concept - if it’s spawned on the client, that client will be considered the authority over that actor (note clients can’t replicate entire actors to the server). If it’s spawned on the server and set to replicate, when the client checks “Has Authority” for that actor, it should return remote.

Depending on what you’re trying to do, you may be able to achieve the desired effect by calling “Is Local Player Controller” on the associated player controller instead.

There is a known bug, which should be fixed in 4.8, where player controllers were reporting incorrect authority during the “Begin Play” event. I’m not sure this is what you’re seeing since it doesn’t look like you’re checking in a player controller blueprint, but in case it is, doing the authority check in the “Post Login” event of the game mode is a potential workaround. Note this event is only called on the server, so you may need to call your own replicated event from here to perform logic on the client.

Oh, that explains why it isn’t working. I’m trying to make different menus appear depending on whether the game is currently a server or client. I tried “Is Local Player Controller” but it’s returning true for both server and client. Is there a different way to check whether the HUD is on a server or client instance?

The easiest solution is probably to do the authority check on the player controller or character/pawn, then forward the result via an event or function to the object that was spawned on the client (in this case the HUD).

Ryan,

Thanks for the suggestions! I was able to achieve the desired effect using the “Is Server” function, which I just found.