APawn::GetController
#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
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?