GetTimerRemaining returns -1

Hi, I cannot for the life of me figure out why this is not working.

.h

	UPROPERTY(BlueprintReadWrite, VisibleAnywhere, Category = "Stacking")
	FTimerHandle LifeHandle; 

I have a timer in my begin play function.

void UDts_DamageEffect::BeginPlay()
{
	Super::BeginPlay();

	GetWorld()->GetTimerManager().SetTimer(LifeHandle, this, &UDts_DamageEffect::LifeExpired, fLifeOfEffect, false);
}

and just for testing I am trying to print the time remaining

void UDts_DamageEffect::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
	
	GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Yellow, FString::SanitizeFloat(FTimerManager().GetTimerRemaining(LifeHandle)));
	
}

I keep getting a print of -1 which means the timer doesn’t exist. Am I misunderstanding the point of that function? In blueprint I can pull off the handle and use the “GetTimerRemainingTimeByHandle” function, and print the return value and get the time remaining on the timer.

Can anyone help point me to why I am not able to print the actual time remaining out of C++?

Thanks
Russ

You are creating an empty instance of a timer manager and checking for the remaining time (which is not tracking your timer)

Instead, use the same timer manager that you got from the world when you created it

Change this from:

FTimerManager().GetTimerRemaining(LifeHandle));

to this:

GetWorld()->GetTimerManager().GetTimerRemaining(LifeHandle));

Thank you! I missed an easy one there.