I am new to using GDScript and I'm following the "Your first 2D game" tutorial I am at the part where is has you put position += velocity * delta
but I keep getting a
Parser error: Unexpected token: Identifer:position
I am unsure as to what is wrong because I followed the tutorial step by step. please help
FULL CODE BELOW:
extends Area2D
# How fast player will move (pixel/sec)
export var speed = 400
#Size of the game window
var screen_size
# Called when the node enters the scene tree for the first time.
func _ready():
screen_size = get_viewport_rect().size
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
# The player's movement vector.
var velocity = Vector2.ZERO
if Input.is_action_pressed("move_right"):
velocity.x += 1
if Input.is_action_pressed("move_left"):
velocity.x -= 1
if Input.is_action_pressed("move_down"):
velocity.y += 1
if Input.is_action_pressed("move_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, screen_size)
position.y = clamp(position.y, 0, screen_size)