0 votes

func physicsprocess(delta):

motion.y += gravity 
var friction = false 

if Input.is_action_pressed("ul_rigth"):
   sprite.flip_H = true
   animationPlayer.play("walk")
motion.x = min(motion.x + moveSpeed,maxSpeed)

elif Input.is_action_pressed("ul_left"):
  sprite.flip_h = false
  animationPlayer.play("walk")
  motion.x = max(motion.x - moveSpeed,-maxSpeed)
in Engine by (12 points)

1 Answer

0 votes

The issue is with this line:

motion.x = min(motion.x + moveSpeed,maxSpeed)

Notice that its indent level matches that of the previous if block. That effectively ends the if block so the following elif no longer makes sense.

I'm not sure what your intention is there. If that motion.x line is intended to be part of the if logic, indent it to indicate that. If it's not part of the if logic, then it shouldn't be there at all and needs to be moved to wherever is appropriate.

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