RealDocs

APawn::Controller

property Engine Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: UPROPERTYreplicatedUsing=OnRep_Controller

Description

The controller currently possessing this pawn. Replicated to clients so that simulated proxies know who is controlling a remote pawn. Use GetController() (the inline accessor) rather than reading this field directly.

Caveats & Gotchas

  • On clients this field is replicated but may be null for brief periods during possession handoffs — always null-check via GetController() before use in networked code.
  • Direct writes to this field bypass the OnRep_Controller callback and the NotifyControllerChanged pathway. Always use SetController() or go through AController::Possess() to ensure all listeners are notified.

Signature

TObjectPtr<AController> Controller

Example

Check if a pawn is player-controlled C++
if (APlayerController* PC = Cast<APlayerController>(GetController()))
{
	// Pawn is controlled by a human player
	PC->ClientPlaySound(HitSound);
}

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.