APawn::GetNetConnection
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualoverride
Description
Returns the net connection associated with this pawn, resolved by walking up through the owning PlayerController. Used by the replication system to determine which client connection owns this actor.
Caveats & Gotchas
- • Returns nullptr for AI-controlled pawns and for pawns on the server that are not owned by a player — callers must null-check the result.
- • The connection is resolved through the controller chain at call time; caching the result is unsafe because the controller (and thus the connection) can change mid-session via possession.
- • This override is what allows pawns to inherit net ownership from their PlayerController even though controllers are not directly referenced from the pawn on remote clients.
Signature
virtual class UNetConnection* GetNetConnection() const override Return Type
UNetConnection* Example
Check if a pawn has an active player connection C++
bool AMyPawn::HasActivePlayerConnection() const
{
return GetNetConnection() != nullptr;
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?