RealDocs

APawn::GetController

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

Description

Returns the controller currently possessing this pawn, or nullptr if unpossessed. Cast to APlayerController or AAIController depending on the possession context.

Signature

AController* GetController() const

Return Type

AController*

Caveats & Gotchas

  • Returns null for unpossessed pawns. Always validate before use.
  • In multiplayer, only the server has the authoritative controller reference on server-controlled pawns.

Example

Casting to player controller C++
APlayerController* PC = Cast<APlayerController>(GetController());
if (IsValid(PC))
{
    // This pawn is player-controlled
    PC->SetShowMouseCursor(true);
}

Version History

Introduced in: 1.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.