Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lincolnpepper |
I am taking the tutorial for the game “Dodge The Creeps” and i have encountered an error in scripting that i can’t seem to solve. I saw where someone else had encountered a similar error and they got a reply, but i still cannot get it right. I think the tutorial should have a section where it shows the whole script like in the lesson before it, so you can see what they did and solve your problems without posting a question here.
Anyway, here is the code:
extends Area2D
export (int) var SPEED
var Velocity = vector2
var screensize
func _ready():
screensize = get_viewport_rect().size
func _process(delta):
velocity = Vector2()
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
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
position += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.y, 0, screensize.y)
For some reason the program is telling me that the end bit where the position is updated has unproper indenting. I don’t know why and i have tried several variations, but they all give the same error. What am i doing wrong?
Sorry for the kinda stupid question, but i’m obviously completely new to Godot and GDscript.