AActor::LifeSpanExpired
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtualENGINE_API
Description
Called when the actor's lifespan timer fires (set via SetLifeSpan). The default implementation calls Destroy(). Override to perform cleanup or delay destruction.
Caveats & Gotchas
- • If you override this without calling Super::LifeSpanExpired(), the actor will NOT be automatically destroyed — you must call Destroy() yourself.
- • This is fired by an internal FTimerHandle (TimerHandle_LifeSpanExpired). If the timer subsystem is not running (e.g. during dedicated server shutdown), this may not fire reliably.
- • On replicated actors, LifeSpanExpired is only authoritative on the server. The actor will be destroyed on clients via normal replication teardown, not by a separate timer.
Signature
ENGINE_API virtual void LifeSpanExpired(); Return Type
void Example
Playing an effect before the actor is destroyed C++
void AMyProjectile::LifeSpanExpired()
{
// Spawn a fizzle effect before we disappear
if (FizzleEffect)
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), FizzleEffect, GetActorLocation());
}
Super::LifeSpanExpired(); // Calls Destroy()
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?