APlayerController::UnPossess
#include "GameFramework/Controller.h"
Access: public
Specifiers: virtual
Description
Releases control of the currently possessed pawn without destroying it, calling `OnUnPossess` on the controller and `UnPossessed` on the pawn. After this call `GetPawn()` returns `nullptr`. Override `OnUnPossess` to add custom teardown logic.
Signature
virtual void UnPossess() final Return Type
void Caveats & Gotchas
- • Like `Possess`, this is `final` — override `OnUnPossess` instead.
- • Safe to call when no pawn is possessed (no-op).
- • In multiplayer, only meaningful on the server; the client transitions to spectating automatically.
Example
Detach player from pawn before destroying it C++
void AMyGameMode::KillPlayer(APlayerController* PC)
{
PC->UnPossess();
// Pawn is now uncontrolled — safe to destroy
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.0 | stable | — |
Feedback
Was this helpful?