how to deactivate button for some seconds then activate it again ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kareem_farrag

how to deactivate button for some seconds then activate it again ?

for wall jump and climb

:bust_in_silhouette: Reply From: SQBX

Make a variable in your script such as

var wall_jump_enabled = true

Then add a Timer as a child to your root node. Set the Timer’s wait_time to the time you want wall jumping to be disabled for. Then in your code, when you want to disable wall_jumping, write

wall_jump_enabled = false
$Timer.start() # The timer node may have a different path in your scene

Now, click the Timer node, go into the signals tap (top of the right inspector), look for the timeout signal, double click it, and hit the connect button. Then, in the newly-made function, write

wall_jump_enabled = true

Finally, before the code to check if the player can wall jump, write

if wall_jumping_enabled:

And indent the wall jump-checking code.

Just adding to the existing excellent answer, there is an example where you can see a similar approach here https://kidscancode.org/godot_recipes/3.x/ui/cooldown_button/

(KidsCanCode has some lovely Godot examples)

AndyCampbell | 2023-01-03 18:14