RealDocs

AActor::HasAuthority

function Engine Blueprint Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: UFUNCTIONBlueprintCallable

Description

Returns true if this actor has network authority — i.e., runs on the server or in a standalone game. The canonical guard for server-only gameplay logic.

Caveats & Gotchas

  • Returns true on the server AND on the owning client for autonomous-proxy actors (e.g. a locally controlled pawn); it is not equivalent to 'am I the server'. Use GetNetMode() == NM_DedicatedServer if you need a strict server check.
  • Inlined for performance — it just compares Role == ROLE_Authority, so the cost is negligible.
  • Calling server-only RPCs without this guard will cause an engine warning and the call will be silently dropped on clients.

Signature

bool HasAuthority() const

Return Type

bool

Example

Guard server-only logic C++
void AMyActor::TakeDamage(float Damage, ...)
{
    if (!HasAuthority()) { return; }
    Health -= Damage;
    if (Health <= 0.f) { Destroy(); }
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.