RealDocs

APawn::GetPlayerStateObjPtr

function Engine Since 5.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: const

Description

Returns the PlayerState as a TObjectPtr, exposing the raw smart-pointer representation used internally. Prefer GetPlayerState() in most gameplay code; this overload is intended for engine systems that need the TObjectPtr directly.

Caveats & Gotchas

  • TObjectPtr is implicitly convertible to a raw pointer in non-editor builds, but in editor builds it performs access tracking. Storing the returned TObjectPtr in a local variable will capture the tracked reference — use GetPlayerState() for gameplay logic to avoid unintended tracking overhead.
  • This method exists primarily to support reflection and serialization tooling. There is almost no gameplay scenario where you need this over GetPlayerState().

Signature

TObjectPtr<APlayerState> GetPlayerStateObjPtr() const

Return Type

TObjectPtr<APlayerState>

Example

Pass to a system expecting TObjectPtr C++
// Engine-internal pattern; prefer GetPlayerState() in gameplay code
TObjectPtr<APlayerState> PS = MyPawn->GetPlayerStateObjPtr();
SomeEngineSystem.RegisterPlayerState(PS);

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.