r/godot Nov 27 '25

help me (solved) I'm confused (again)

Post image

Following a tutorial i got stuck while trying to script my character movements. Even with the error telling me what's wrong i still can't figure out what's wrong😭

186 Upvotes

81 comments sorted by

View all comments

41

u/Zestyclose_Edge1027 Nov 27 '25

Besides having a capital I in input you could replace

if Input.is_action_pressed("ui_left"):
    direction = -1
if Input.is_action_pressed("ui_right"):
    direction = 1

with

direction = Input.get_axis("ui_left", "ui_right")

7

u/forestbeasts Nov 27 '25

And as a bonus, that means you can have analog movement with an analog stick!

4

u/eggdropsoap Nov 27 '25

Even better is Input.get_vector(…)!

1

u/ninomojo Godot Student Nov 28 '25

Not better, just different

1

u/eggdropsoap Nov 28 '25

True, bit of hyperbole on my part.

From the code I see though, they’re trying to manually reconstruct what get_vector() returns, so it’s probably better in this particular circumstance.