Timer crashing UE4 C++

Velvatrax
Fri, 11 Nov 2016 04:02:42 +0000
C++

Hello everyone,

I making a lantern class that slowly uses fuel over time so I tried to setup a timer to handle fuel consumption. The Drain function decreases the fuel level of the Lantern. I am trying to make it so that the Drain function is called every 1 second. Thank you for your help, below is the code I am using to handle the timer. Any advice is appreciated!

ALantern::ALantern()
{
	PrimaryActorTick.bCanEverTick = true;
	Fuel_Level = 10000.0f;
	FTimerHandle Timer;
	GetWorldTimerManager().SetTimer(Timer, this, &ALantern::Drain, 1.0f, true, 3.0f);
}

4 posts - 3 participants