Hello,
This is because your if s are all tested, so in the last one :
if Input.is_action_pressed("ui_down"):
test = true
else:
test = false
the test = false
part will run if the ui_down
action is not pressed, regardless of other actions.
You should use elif
(shorthand for else
and if
combined) to prevent this:
var test = false
func process(delta):
if test == true:
$AnimatedSprite.play("walk")
if Input.is_action_pressed("ui_left"): # ui_left ?
test = true
elif Input.is_action_pressed("ui_right"): # then, ui_right ?
test = true
elif Input.is_action_pressed("ui_up"): # then, ui_up ?
test = true
elif Input.is_action_pressed("ui_down"): # then, ui_down ?
test = true
else:
# none of them is pressed
test = false