The identifier "facing_right" isn't declared in the current scope.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Suikurx
func _physics_process(delta):

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

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

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

if Input.is_action_pressed("ui_right"):
	motion.x += ACCEL
	facing_right = true
elif Input.is_action_pressed("ui_left"):
	motion.x -= ACCEL
	facing_right = false

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

:bust_in_silhouette: Reply From: Help me please

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):