Following a tutorial, my player wont move

Godot Version

4.2.2

Question

I’ve been following a web tutorial for making a player character move on Godot Docs, but there isn’t any help for what i have been seeing?
The code i have is here (changed the names of files to not have _ ), and here is what the game looks like when i go and run it with the current code.



I might just find a different way to code this, but it might just be a small and easy fix idk how to do. Since the sprite i made is stuck in the upper left, and the buttons i set up wont do anything i wrote them to do.

Strange tutorial, you need to un-indent the position changing lines.

if velocity.length() > 0:
    velocity = velocity.normalized() * speed
    $AnimateSprite2D.play()
else:
    $AnimatedSprite2D.stop()

position += velocity * delta

otherwise your code is saying “if velocity is zero, add it (zero) to position”

You can paste code by pressing the </> button on a new line like so

```
type or paste code here
```

It is a strange tutorial, i should probably just stick to video lessons after this lol.

Anyways when i do this, it says its an “unexpected if statement” and the tutorial just had it like that with no function before it on what i assume was a good tutorial. I’m gonna see if there is any other tutorials for this in the meanwhile because everything is good from what i can tell.

Thank you for the help btw, it did let me know why the issue was happening and to what area :]

I believe you un-indented too much! The sample I provided should still have one tab behind each line; just the position += velocity*delta and the clamp that followed needed to be un-indented.