RealDocs

AActor::HasNetOwner

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

Description

Returns true if this actor has an owner chain that leads to an actor capable of net ownership, typically an APlayerController. Used by the replication system to determine if the actor can initiate RPCs.

Caveats & Gotchas

  • Ownership is determined by walking the Owner chain, not by checking the local machine's role — an actor owned by a bot controller will return false because bots don't have net connections.
  • Overriding this function is required for custom actor types that aggregate ownership differently (e.g. vehicles that own passengers); the default implementation does a linear walk up the Owner chain which can be slow for deep hierarchies.
  • This differs from HasAuthority() — an actor can have a net owner on a client (it's owned by the local player controller) without having server authority.

Signature

ENGINE_API virtual bool HasNetOwner() const;

Return Type

bool

Example

Gate an RPC call on net owner presence C++
void AMyActor::RequestAction()
{
    if (HasNetOwner())
    {
        // Safe to call a Server_ RPC
        Server_DoAction();
    }
}

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.