0 votes
func _physics_process(delta):

motion.y += GRAVITY
if motion.y > MAXFALLSPEED:
    motion.y = MAXFALLSPEED

if facing_right == true:
    $Sprite.scale.x = 1
else:
    $Sprite.scale.x = -1

motion.x = clamp(motion.x, -MAXSPEED, MAXSPEED)

if Input.is_action_pressed("ui_right"):
    motion.x += ACCEL
    facing_right = true
    $Sprite/AnimationPlayer.play("Running")
elif Input.is_action_pressed("ui_left"):
    motion.x -= ACCEL
    facing_right = false
    $Sprite/AnimationPlayer.play("Running")
else:

When I type "if facing_right == true:" the error shows up. Is there a way I can fix this?

Godot version 3.3.2
in Engine by (25 points)

1 Answer

0 votes
Best answer

It is because you have not declared what facing_right is
So you must specify that it is a variable as below

var facing_right = false # or true as per game
func _physics_process(delta):
    .......
by (884 points)
selected 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 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.