how do you get var to work if i ass inputs into var?

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

Hi, i was wondering if there’s a way to put input into var because right now i have this:

const SPEED = 180

var velocity = Vector2.ZERO
var left = Input.is_action_pressed(“ui_left”)

func _physic_process(delta):
if left:

enter code herevelocity.x = -SPEED
$AnimatedSprite.play(“walk”)
$AnimatedSprite.flip_h = true

but when i test play, my character isn’t moving.

That won’t work. Input.is_action_pressed("ui_left") returns a bool value, and that value is just assigned once to the var. Whenever you press ui_left again, the variable won’t update.
You either define another function left() which returns Input.is_action_pressed("ui_left"), or you make the assigmet inside _physics_process.

p7f | 2020-07-07 18:45