RealDocs

AActor::OnEndPlay

property Engine Blueprint Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: UPROPERTYBlueprintAssignable

Description

Delegate broadcast whenever this actor's play session ends for any reason — explicit destruction, level unload, game end, or streaming out. More reliable than OnDestroyed for general cleanup.

Caveats & Gotchas

  • The EEndPlayReason::Type parameter tells you why EndPlay occurred. Check it to distinguish between destruction (Destroyed), level transition (LevelTransition), and application exit (Quit) if your cleanup logic differs.
  • OnEndPlay fires before OnDestroyed. If you bind to both, OnEndPlay will run first.

Signature

UPROPERTY(BlueprintAssignable, Category="Game")
FActorEndPlaySignature OnEndPlay

Examples

Disable collision and hide this actor when its play session ends Blueprint
Event End Play Actor End Play Reason End Play Reason Set Actor Enable Collision Target is Actor Target New Actor Enable Collision New Actor Enable Collision false false Set Actor Hidden In Game Target is Actor Target New Hidden true
Edit Blueprint graph Disable collision and hide this actor when its play session ends
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Bind OnEndPlay to release a pooled resource C++
MyActor->OnEndPlay.AddDynamic(this, &AMySystem::HandleEndPlay);

void AMySystem::HandleEndPlay(AActor* Actor, EEndPlayReason::Type EndPlayReason)
{
    ResourcePool.Release(Actor);
}

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.