+2 votes

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

for wall jump and climb

in Engine by (59 points)

1 Answer

+1 vote

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 waittime to the time you want wall jumping to be disabled for. Then in your code, when you want to disable walljumping, 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.

by (731 points)

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)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.