RealDocs

APawn::Destroyed

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

Description

Called when this pawn is destroyed. The APawn override detaches it from its controller before the actor is removed from the world.

Caveats & Gotchas

  • Always call Super::Destroyed() in your override — the base implementation calls DetachFromControllerPendingDestroy() which is essential for correctly cleaning up the controller-pawn relationship and preventing dangling pointers.
  • Destroyed() is called before EndPlay(); at the time Destroyed() fires, component BeginDestroy() has not yet been called, so you can still safely access components to clean up state.

Signature

ENGINE_API virtual void Destroyed() override;

Return Type

void

Example

Override Destroyed to notify game systems before the pawn is removed C++
void AMyPawn::Destroyed()
{
    // Notify the game mode before the controller is detached
    if (AMyGameMode* GM = GetWorld()->GetAuthGameMode<AMyGameMode>())
    {
        GM->OnPawnDestroyed(this);
    }
    Super::Destroyed(); // Detaches from controller
}

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.