Hi,
I was using some timers in my project and was wondering about what the best practices are revolving around them. I found myself using them in two different ways, which I’ll post as little snippets here:
if Input.is_action_pressed("Shoot") && can_shoot:
can_shoot = false
$ShotTimer.start()
#DoShootingStuff
func _on_timer_timeout(): #Catching the timer signal
can_shoot = true
And the other way is
func hit():
if $TimerOne.is_stopped():
$TimerOne.start() #0.5s timer
$TimerTwo.start() #0.1s timer
#Do A Thing
elif $TimerTwo.is_stopped(): #Thing 1 is on cooldown, do Thing 2?
$TimerTwo.start() #0.1s timer
#Do A Different Thing
else: #Both Things are on cooldown, do nothing
pass
Is using one of these strategies always better than the other or are there circumstances where it can be different?