RealDocs

AActor::GetLifeSpan

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

Description

Returns the remaining lifespan of this actor in seconds. Returns 0 if the actor has no lifespan timer set (i.e., it lives indefinitely).

Caveats & Gotchas

  • A return value of 0 is ambiguous — it means either no timer is set, or the timer expired this frame just before the call. Do not rely on this to detect imminent destruction; bind to `OnEndPlay` instead.
  • The returned value counts down in dilated time (accounting for `CustomTimeDilation` and world dilation), consistent with how `SetLifeSpan` sets the timer.

Signature

ENGINE_API virtual float GetLifeSpan() const;

Return Type

float

Examples

Print a warning when the actor's lifespan drops below 3 seconds Blueprint
Event Tick Delta Seconds Delta Seconds Branch Condition Condition True False Print String In String Expiring soon! Expiring soon! Get Life Span Target is Actor Return Value Return Value < A B 3.0 Return Value Return Value
Edit Blueprint graph Print a warning when the actor's lifespan drops below 3 seconds
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Warn when a buff is about to expire C++
void AMyBuffActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	const float Remaining = GetLifeSpan();
	if (Remaining > 0.f && Remaining < 3.f)
	{
		// Flash UI warning
		OnExpiryWarning.Broadcast(Remaining);
	}
}

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.