This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
–1 vote

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
in Engine by (30 points)

1 Answer

+1 vote
Best answer

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)

by (46 points)
selected by

I got the problem fixed

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

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.