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.