AActor::GetNetOwningPlayerAnyRole
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtualENGINE_API
Description
Returns the owning UPlayer for this actor regardless of its current net role. Unlike GetNetOwningPlayer(), this works on both authority and simulated proxies.
Caveats & Gotchas
- • Use this instead of GetNetOwningPlayer() when you need the owning player on the client side, for example to drive local UI or input binding tied to an actor that may be a simulated proxy.
- • On a dedicated server, every actor's owning player comes back as a UNetConnection; only on listen servers or standalone builds will you get a ULocalPlayer.
- • Overriding this in a subclass requires you to also override GetNetOwningPlayer() if authority-only checks are important for your use case.
Signature
ENGINE_API virtual class UPlayer* GetNetOwningPlayerAnyRole() Return Type
class UPlayer* Example
Get owning player regardless of net role C++
UPlayer* OwningPlayer = MyActor->GetNetOwningPlayerAnyRole();
if (ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(OwningPlayer))
{
// This actor is owned by a local player — safe to update local UI
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?