Cooldown timer implementation

Godot Version

<v4.1.1>

Question

<Hello what’s the best way to go about implementing a timer that disables a specific key input for a certain amount of time after its pressed? >

I like using the animation systems. Especially if there is, or will be, a visual aspect to it. Super easy almost no code except for the animation finished signal and state update.

1 Like

Would you have a resource to point to? I’m looking for something like that too and it’d be nice to check what others have done, if such a thing can be found. So far my search has been fruitless.

The video doesn’t go over the subject per se, but it does show you how to use animation trees.

But let’s make it simple. Attach an animationplayer to the scene.

In the animation tab on the bottom add a new animation with a name, and set it to the desired length of time you want it to cool down. (We can add real animations later)

Then in the code you call the node

#ready
$animationplayer.finished.connect(func(): cooldown = false)

#player input or stats change
$animationplayer.play("my_cooldown_animation")
cooldown = true
2 Likes