0 votes

I'm trying to check if an action is not pressed and I think this should work but I'm not sure.

if !Input.is_action_pressed("Move_Left") or !Input.is_action_pressed("Move_Left") or timer_counting == false:

all I'm trying to do is basically an "else" to the input detections but with the added check for a timer that serves as a cooldown.

in Engine by (60 points)

You don't have to put in the extra !Input.is_action_pressed("Move_Left").

Your code will check for whether one of those two statements is true. The implication of the code if !Input.is_action_pressed("Move_Left") or timer_counting == false:, though, is that it will return true for any situation where Input.is_action_pressed("Move_Left") is not being pressed , or the timer isn't counting. It may be better to first check for the cooldown and then check for the input, e.g.

if not timer_counting:
     if Input.is_action_pressed("Move_Left"): # Or "Move_Right", "Move_Up", "Move_Down", etc.
            # Your glorious movement code goes here.

Hope that helps.

personally I like not instead of ! because sometimes when trying to find an annoying bug and you know your error was because of ' ! ', which can be hard to find sometimes.

Wow, Thx so much

1 Answer

0 votes

it should work, but the best way to check is to compile and test it!

by (439 points)
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 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 webmaster@godotengine.org with your username.