This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

So I was following a tut on yt and this bit of code won't work


func move(delta):

axis = get_input_axis()

if axis == Vector2.ZERO
    pass #apply friction

else:
    pass #apply movement

move_and_slide()
-----------------------------------------------------

This is in a 2d world and all that jazz but the main thing that won't work is the
"if axis == Vector2.ZERO" The tut used a long = so I thought it was just a = but twice but I was wrong and it won't work no matter what I do.
Any help is appreciated

Godot version 4.0
in Engine by (12 points)
edited by

1 Answer

+3 votes

You’re missing a colon on the if statement.

if axis == Vector2.ZERO:

It’s always worth double-checking against the source material to confirm the code is the same, and then checking again (and in this case, reading the error message). Potentially fixing the indentation too, although I assume that’s the forum.

by (1,406 points)
edited by
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.