Looking for a more efficient way to handle ability cool downs

I started making a FPS game with abilities and when following a tutorial created a scheme that honestly seems really inefficient. As you can see below there are three functions being used. Isn’t there a way this could be reduced to two or maybe even one?

void AShooterCharacter::TacticalAbility()
{
	if(!bTacticalUsed)
	{
		//do ability
                bTacticalUsed = true;
        }


	GetWorld()->GetTimerManager().SetTimer(TacticalTimerHandle, this, 
        &AShooterCharacter::TacticalReset, TacticalDuration, false);

}

void AShooterCharacter::TacticalReset()
{
	//undo ability 
        GetWorld()->GetTimerManager().SetTimer(TacticalTimerHandle, this, 
        &AShooterCharacter::TacticalCoolDownComplete, TacticalCoolDownRate, false);	
}

void AShooterCharacter::TacticalCoolDownComplete()
{
        bTacticalUsed = false;
}

Just reiterating, this scheme for handling cooldowns seems really inefficient to me and I wanted to see if anyone out there has a better method for doing it.

i think thats pretty standard but alternatively what you could do is save a time stamp and compare it to the world timer.

so if an ability is used at time x and the cooldown is 30seconds the you compare is world time >= x+30

1 Like