UActorComponent::GetOwnerRole
#include "Components/ActorComponent.h"
Access: public
Specifiers: const
Description
Returns the network role of the actor that owns this component, or ROLE_None if the component has no owner. Use this to make authoritative vs simulated decisions inside component code.
Caveats & Gotchas
- • Components do not have their own net role — this delegates to GetOwner()->GetLocalRole(). If the component is not attached to an actor (e.g. called during construction before attachment) it returns ROLE_None.
- • ROLE_AutonomousProxy means the local player controls the owning actor; ROLE_SimulatedProxy means another player controls it. ROLE_Authority means this machine is the server or the actor is not replicated.
Signature
ENGINE_API ENetRole GetOwnerRole() const Return Type
ENetRole Example
Authority guard inside a component C++
void UMyComponent::DoServerAction()
{
if (GetOwnerRole() != ROLE_Authority)
{
// Not the server — don't execute authoritative logic
return;
}
ApplyServerSideEffect();
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?