AActor::RouteEndPlay
#include "GameFramework/Actor.h"
Access: public
Specifiers: ENGINE_API
Description
Non-virtual engine function that evaluates which portions of the EndPlay process to dispatch for this actor, then calls EndPlay on the actor and all its components in the correct order.
Caveats & Gotchas
- • Do not call this directly from game code — it is invoked by the engine's destruction pipeline. Calling it manually can cause double-EndPlay on components and leave the actor in an inconsistent state.
- • RouteEndPlay is non-virtual by design. Override EndPlay() on the actor or on individual components to add teardown logic; do not try to intercept at the RouteEndPlay level.
- • The EndPlayReason passed through here is forwarded to all component EndPlay calls, so component cleanup code can distinguish between actor destruction and level unload.
Signature
ENGINE_API void RouteEndPlay(const EEndPlayReason::Type EndPlayReason); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| EndPlayReason | const EEndPlayReason::Type | The reason EndPlay is being called (destroyed, level unloaded, game ended, etc.). | — |
Return Type
void Example
Override EndPlay instead C++
// Override EndPlay, not RouteEndPlay
void AMyActor::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
if (EndPlayReason == EEndPlayReason::Destroyed)
{
// Cleanup specific to destruction
CleanupResources();
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?