system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
JTJonny |
|
Old Version |
Published before Godot 3 was released. |
I’m trying to clean up some code that has a ton of if statements with a ton of:
Input.is_action_pressed("inputName")
I thought you could clean it up by putting it in a variable:
var pressUp = Input.is_action_pressed("ui_up")
It does not seem to work. It lets me run the game, but the inputs stop working. I’m pretty sure I’m missing something simple.
system
4
|
|
|
|
Reply From: |
Daniel Lewan |
Sure. Input.is_action_pressed
returns bool so you can use it like this:
var left = Input.is_action_pressed("ui_left")
var rigt = Input.is_action_pressed("ui_right")
if left:
something
elif rigt:
something
else:
something
Thank you for taking that off my list, so I could fine what was really wrong. It ended up being a logic problem.
JTJonny | 2016-03-18 19:41
@JTjonny ~ If this answer has outlined the solution, make sure to mark it as “accepted” by checking the checkmark :).
Bojidar Marinov | 2016-03-19 09:53
@Bojidar Marinov - Sorry, new to this. I just did it.
JTJonny | 2016-03-19 17:07