RealDocs

AActor::GetNetConnection

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

Description

Returns the owning net connection for this actor, used to determine which client connection owns and controls it. Returns null for actors that have no net owner.

Caveats & Gotchas

  • Walks the Owner chain to find the first actor with a net connection — overriding Owner on intermediate actors changes which connection is returned.
  • Returns null on the server for actors not owned by a player controller, not null for the server's own connection (which doesn't exist).
  • Overriding this is valid for custom ownership models (e.g., a vehicle that should report its passenger's connection); call Super only if you want the default chain walk.

Signature

ENGINE_API virtual class UNetConnection* GetNetConnection() const

Return Type

class UNetConnection*

Example

Check if actor is owned by a specific player's connection C++
bool AMyActor::IsOwnedByPlayer(APlayerController* PC) const
{
    return GetNetConnection() == PC->GetNetConnection();
}

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.