facing_right = false (Parser Error: Unindent does not match any outer indentation level.)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Erto

Hi.

Im following a youtube tutorial by Eli Cuaycong (https://www.youtube.com/watch?v=xFEKIWpd0sU)

And for some reason, it says: Unindent does not match any outer indentation level. In the video, there isn’t an issue like that. And looking at the code I can’t find a reason using my own logic either.

I would appreciate some help.
Thanks!

enter coextends KinematicBody2D


const UP = Vector2(0,-1)
const GRAVITY = 20
const MAXFALLSPEED = 200
const MAXSPEED = 200
const JUMPFORCE = 400
const ACCEL = 10

var motion = Vector2()
var facing_right = true


func _ready():
pass 


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("right"):
	motion.x += ACCEL
	facing_right = true
	$AnimationPlayer.play("RUN")
elif Input.is_action_pressed("left"):
	 motion.x -= ACCEL
	facing_right = false <- this DOESNT WORK
	$AnimationPlayer.play("RUN")

else:
	motion.x = lerp(motion.x,0.0.2)
	$AnimationPlayer.play("IDLE")
	
if is_on_floor():
	if Input.is_action_just_pressed("jump"):
		motion.y = -JUMPFORCE
		
		if !is_on_floor():
	if motion.y < 0:
		$AnimationPlayer.play("JUMP")
	elif: motion.y > 0:
		$AnimationPlayer.play("FALL")
motion = move_and_slide(motion,UP)
de here
:bust_in_silhouette: Reply From: lightyears

Indent your code with 4 spaces or a tab in _ready and _physics_process should resolve the problem.

extends KinematicBody2D

const UP = Vector2(0,-1)
const GRAVITY = 20
const MAXFALLSPEED = 200
const MAXSPEED = 200
const JUMPFORCE = 400
const ACCEL = 10

var motion = Vector2()
var facing_right = true

func _ready():
    pass 


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("right"):
    motion.x += ACCEL
    facing_right = true
    $AnimationPlayer.play("RUN")
elif Input.is_action_pressed("left"):
    motion.x -= ACCEL
    facing_right = false
    $AnimationPlayer.play("RUN")
else:
    motion.x = lerp(motion.x,0.0.2)
    $AnimationPlayer.play("IDLE")

if is_on_floor():
    if Input.is_action_just_pressed("jump"):
        motion.y = -JUMPFORCE

    if !is_on_floor():
        if motion.y < 0:
            $AnimationPlayer.play("JUMP")
        elif motion.y > 0:
            $AnimationPlayer.play("FALL")
motion = move_and_slide(motion,UP)
```

I got the problem fixed

Thank you for the help. I didn’t even think to look there for the mistake.

Erto | 2023-02-25 22:19