AActor::GetLocalRole
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableconst
Description
Returns the net role of this actor on the current machine — `ROLE_Authority` on the server, `ROLE_SimulatedProxy` or `ROLE_AutonomousProxy` on clients.
Caveats & Gotchas
- • For most authority checks, prefer `HasAuthority()` which reads `GetLocalRole() == ROLE_Authority`. It is more readable and less error-prone than comparing the enum directly.
- • `ROLE_AutonomousProxy` means this machine controls the actor (e.g. local player's character). `ROLE_SimulatedProxy` means it's a remote actor being simulated locally. The distinction matters for client-side prediction.
- • The `Role` property was historically public and settable; from UE5 it is private, readable only through this getter. Do not cache the value across frames — it can change during seamless travel or when replication is toggled.
Signature
UFUNCTION(BlueprintCallable, Category=Networking)
ENetRole GetLocalRole() const { return Role; } Return Type
ENetRole Example
Differentiate simulated vs autonomous proxy on client C++
void AMyCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (GetLocalRole() == ROLE_AutonomousProxy)
{
RunClientSidePrediction(DeltaTime);
}
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?