RealDocs

APawn::GetController

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

Description

Returns the controller currently possessing this pawn, or null if unpossessed. A templated overload exists for casting directly to a specific controller type.

Caveats & Gotchas

  • Returns null on remote clients in a multiplayer session because AController is not replicated to non-owning clients — always check HasAuthority() or IsLocallyControlled() before relying on the result.
  • The templated version GetController<T>() is a convenient Cast<T> wrapper; prefer it when you already know the expected type to avoid a separate cast.

Signature

AController* GetController() const;

Return Type

AController*

Examples

Cast the pawn's controller to PlayerController and enable input Blueprint
Event BeginPlay Get Controller Target is Pawn Target Return Value Cast To PlayerController Object Cast Failed As Player Controller As Player Controller Enable Input Target is Actor Target Player Controller Player Controller
Edit Blueprint graph Cast the pawn's controller to PlayerController and enable input
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Get the player controller driving this pawn C++
APlayerController* PC = GetController<APlayerController>();
if (PC)
{
    // This pawn is controlled by a player
    PC->ClientPlaySound(SomeSound);
}

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.