Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | yerbestpal |
Hi folks,
I have a player node that has an attack (we’ll call it kick) which I need a cooldown for between triggering the attack and the next time I use it. So, if I kick, it should be 0.5 seconds until I can kick again.
Currently I am using a timer to achieve this. When I enter my kick state, the kick timer may only trigger is the timer has stopped:
states.kick:
if parent.kick_cooldown.is_stopped():
parent.kick_cooldown.start(0.5)
This actually works; I cannot enter the state until the timer hits zero. Unfortunately, it only works if I do not spam the kick button. If I do spam input, it is impossible to kick again. I have to allow the timer to spend some time having stopped. This is how that looks when I print the output:
time left: 0.05
time left: 0.05
time left: 0.033333
time left: 0.033333
time left: 0.016667
time left: 0.016667
time left: 0
time left: 0
time left: 0.483333
time left: 0.483333
time left: 0.466667
time left: 0.466667
Clearly, the timer stops, and thus I should be able to kick again, but this is not the case.
Any help here is much appreciated, and if I can provide any more information, then I will. Thanks.