InitialLifeSpan not working

Hi,

I’m using ue 4.6 precompiled.

Constructor of Actor

InitialLifeSpan = 5.0f;
bAutoDestroyWhenFinished = true;
bCanBeDamaged = true;

In my BeginPlay() i got a log for showing how much time is left.

BeginPlay()

UE_LOG(G1Log, Log, TEXT("BEGIN Lifetime: %f   remaining: %f"),InitialLifeSpan, GetLifeSpan());

Lifetime: 5 and remaining: 0
The LifeSpanExpired() is never triggered.
Can someone explain why this is happening. GetLifespan = 0 means it lifes forever.

Hack Fix:
i could set the initiallifespan with setLifespan(InitialLifeSpan) in the BeginPlay but this is more like a hack.

I know this is old, but I just solve this for me. Check if you didn’t forget to call

Super::BeginPlay();

at the beginning of your beginPlay, thats where lifeSpan is setup.

1 Like

4.26 pr6
same thing, default settings VS 2019, FPS shooter project, all defaults , I change the initialLifespan in the projectile.cpp to any number , or 0 (for inifinite) but the projectile ball always disappears after 3 seconds (the default lifespan).

Did you manage to fix that? I’m having exactly the same problem with the FPS tutorial, the only difference being, that the projectile never disappears.

Actually you have to set InitialLifeSpan before you call the parental BeginPlay function.

void AProjectile::BeginPlay()
{
	InitialLifeSpan = 10.f;

	Super::BeginPlay();
}