RealDocs

APawn::GetNetOwningPlayer

function Engine Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: virtualoverride

Description

Returns the UPlayer that owns this pawn for network purposes. The pawn implementation returns the player from its controller when one is present, which is used to determine the net connection for reliable actor relevancy and RPC delivery.

Caveats & Gotchas

  • Returns null for AI-controlled pawns because AIControllers do not have an associated UPlayer — only pawns possessed by a PlayerController will return a valid UPlayer from this function.
  • The engine calls this internally to resolve which UNetConnection the actor replicates over; overriding it incorrectly can silently break replication for all actors owned by this pawn.

Signature

ENGINE_API virtual UPlayer* GetNetOwningPlayer() override;

Return Type

UPlayer*

Example

Check if pawn has a player network connection C++
UPlayer* Player = MyPawn->GetNetOwningPlayer();
if (Player)
{
    // This pawn is associated with a player connection
    UNetConnection* Conn = Cast<UNetConnection>(Player);
}

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.