0 votes

Does tab indent cause problems?
i get "Unindent does not match any outer indentation level" error.

https://i.imgur.com/35RN5wC.jpg

extends Node2D

var speed = 100
var vel = Vector2()

func _ready():
    set_process(true)

func _process(delta):
    vel = Vector2()
    if Input.is_key_pressed(KEY_RIGHT):
        vel = Vector2(speed, 0) 
    if Input.is_key_pressed(KEY_LEFT):
        vel = Vector2(speed, 0)
    translate(vel * delta)

Converting to space indent solved the problem.
However, space indents are not good looking.
Is there a way to solve it?
https://godotengine.org/qa/28306/error-unindent-does-not-match-any-outer-indentation-level
i try this tutorial, but problem is can not solved

in Engine by (182 points)

1 Answer

+1 vote

No Tab indenting is not bad.
Just don't mix space and tab indenting in one block like you did in the screen shot.

Your error:
vel = was indented with spaces and the next line(s) were indented with tabs.

Generally set your indenting in Editor->Preferences then "Text Editor->Indent".

Problems usually arise if you copy text from other sources which used the "other" editing and then edit it using your own preferences. Or if you use an exeternal editor with different indenting settings.

by (3,214 points)
edited by

Thank you!
I had overlooked space indent

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.

Categories