0 votes
if(btn_l):
    set_linear_velocity(Vector2(-100,get_linear_velocity().y))
elif(btn_r):
    set_linear_velocity(Vector2(100,get_linear_velocity().y))
elif(btn_u):
    set_linear_velocity(Vector2(get_linear_velocity().x, 50)
else:
    set_linear_velocity(Vector2(0,get_linear_velocity().y))

Error parsing expression, misplaced ":"
(at else part)

if i remove second elif then it works fine. when i add second elif then it shows error. does godot support nested if else or not?

in Engine by (12 points)
edited by

1 Answer

+1 vote
elif(btn_u):
    set_linear_velocity(
                        Vector2(
                                get_linear_velocity().x, 50
                               )

You are missing a )

by (7,946 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 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.