RealDocs

APawn::GetNetOwningPlayerAnyRole

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

Description

Variant of GetNetOwningPlayer() that returns the owning UPlayer regardless of the actor's net role. Used by the engine in contexts where the role check in the base version would incorrectly return null.

Caveats & Gotchas

  • This override exists to handle edge cases in replication where the standard role-gated GetNetOwningPlayer() returns null prematurely — prefer GetNetOwningPlayer() in game code unless you understand why you need the unchecked version.
  • Because it bypasses the role check, using this on a dedicated server for actors not yet fully replicated can return a player connection that does not match the intended owning client.

Signature

ENGINE_API virtual UPlayer* GetNetOwningPlayerAnyRole() override;

Return Type

UPlayer*

Example

Engine internal usage (rarely called from game code) C++
// Used by the engine's net driver internally:
// UPlayer* P = Actor->GetNetOwningPlayerAnyRole();
// In game code, prefer GetNetOwningPlayer():
UPlayer* Player = MyPawn->GetNetOwningPlayer();

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.