+1 vote

So i started godot having no idea what the hell im doing then i found the pdf file of the tutorial and downloaded it:
Followed step by step learning functions and made the player node along with sprite and collision configuration, however when i reached the scripting part especially the "movement input i got an error message that i couldn't find a work around here is the code

#movement input
if Input.is_action_pressed("moved_left"):
vel.x -= speed
if Input.is_action_pressed("moved_right"):
vel.x += speed

I'm also having problems with the reset horizontal velocity as after i type

vel.x = 0 

I get another unexpected token error

If if will help here's an image:

Godot version 3.3.4
in Engine by (19 points)

1 Answer

0 votes

"Unexpected token" is what you get when you try to run code outside a function.

Every line of code from line 20 down needs to be indented by one tab, so that it belongs to the process function.

by (20,677 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.