APawn::PreviousController
#include "GameFramework/Pawn.h"
Access: public
Specifiers: UPROPERTYtransient
Description
Stores a reference to the controller that possessed this pawn immediately before the most recent controller change. Available within the NotifyControllerChanged / ReceiveControllerChanged callback window.
Caveats & Gotchas
- • This property is marked Transient and is NOT replicated. On clients it is always null; only read it in server-side or standalone controller-change callbacks.
- • The reference is not cleared after the change notification completes, so do not store a pointer to it beyond the scope of the change callback — the old controller may be destroyed, leaving a stale but GC-protected reference.
Signature
TObjectPtr<AController> PreviousController Example
Log controller handoff during possession change C++
void AMyPawn::NotifyControllerChanged()
{
Super::NotifyControllerChanged();
UE_LOG(LogTemp, Log, TEXT("Controller changed from %s to %s"),
PreviousController ? *PreviousController->GetName() : TEXT("None"),
Controller ? *Controller->GetName() : TEXT("None"));
} Tags
Version History
Introduced in: 5.1
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?