0 votes
extends Area2D

export var speed = 400
var screen_size

func _ready():
screen_size = get_viewport_rect().size

func _process(delta):

var velocity = Vector2()  # The player's movement vector.
if Input.is_action_pressed("ui_right"):
    velocity.x += 1
if Input.is_action_pressed("ui_left"):
    velocity.x -= 1
if Input.is_action_pressed("ui_down"):
    velocity.y += 1
if Input.is_action_pressed("ui_up"):
    velocity.y -= 1
if velocity.length() > 0:
    velocity = velocity.normalized() * speed

position += velocity * delta
position.x = clamp(position.x, 0, screen_size.x)
position.y = clamp(position.y, 0, screen_size.y)

I copied the tutorial and code exactly as it said yet I still get an error that says - error (26,1): Unindent does not match any outer indentation level.
I've read others questions on lining up the indents with the if's and the else but I lined them up but the error still persisted. I really want to learn a real game engine that's not something like code.org but this is already a weird language to me with all the indenting.

in Engine by (17 points)

1 Answer

0 votes
Best answer

Those lines under func _process(delta): should be indented.

This is most common when you copy-and-paste instead of typing the code yourself. Copying from a webpage will usually destroy the formatting of code. In addition, you should really be typing it yourself, as it will result in much more understanding and retention, even if you're just following along with a tutorial.

by (20,673 points)
selected by

It doesn't show in the code format in the question but the lines under the func _process(delta); are indented by one each

Disregard that after going back and re-indenting everything manually the error went away but that leaves me with a side question how exactly does the indentation system work in this language?

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.