+2 votes

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:
https://ibb.co/sCcrs30

Godot version 3.3.4
in Engine by (57 points)

1 Answer

+1 vote

"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 (21,940 points)
"Unexpected token: Identifier:velocity"

Thank you, the doc must be old. It didn't give a reason or showed in images to double indent. Much appreciated

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 Frequently asked questions and 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 [email protected] with your username.