Why does this work on !HasAuthority?

I’ve got a function on my playercontroller that gets called at begin play and it calls the server function that increases my players resources. It was getting double called for a single tick at the beginning so I changed to HasAuthority() to run it on the server and it only ran once. But it seems to work when not has authority is used. Why is this?

negating has authority returns if an actor doesn’t have network authority.

You can narrow this down with GetNetMode

GetNetMode() returns an enum ENetMode where you can compare

ENetMode::NM_DedicatedServer
ENetMode::NM_Client
ENetMode::NM_ListenServer
ENetMode::NM_Standalone

for more granular control

so

if(GetNetMode() == ENetMode:::NM_Client){
}

would check if it’s a client

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.