AActor::InitialLifeSpan
#include "GameFramework/Actor.h"
Access: public
Specifiers: UPROPERTYEditAnywhereBlueprintReadOnly
Description
How many seconds this actor lives before being automatically destroyed. A value of 0 means the actor lives forever. This is the initial value set before play begins and should not be modified after BeginPlay.
Caveats & Gotchas
- • This is the INITIAL value read at BeginPlay to call SetLifeSpan() — modifying it after BeginPlay has no effect. Use SetLifeSpan() at runtime to change the countdown.
- • The countdown is measured in real game time and respects global time dilation from WorldSettings; if TimeDilation is 0, the actor will never expire regardless of this value.
- • BlueprintReadOnly means Blueprint graphs cannot write to this field; to set it from Blueprint, use SetLifeSpan() instead.
Signature
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Actor)
float InitialLifeSpan; Examples
Branch on whether the actor has a limited lifespan
Blueprint
Set a 5-second lifespan on a spawned projectile C++
AProjectile* Proj = GetWorld()->SpawnActor<AProjectile>(ProjectileClass, SpawnTM);
if (Proj)
{
Proj->InitialLifeSpan = 5.0f; // Set before FinishSpawning or in constructor
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?