This is my code right now:
extends Area2D
var screenWidth # var para limite de pantalla
var screenHeight # var para limite de pantalla
var speed = 400.0
#funcion para limite de pantalla
func _ready():
screenWidth = get_viewport_rect().size.x
screenHeight = get_viewport_rect().size.y
#el personaje camina
func _process(delta):
var direction = Vector2.ZERO
if Input.is_action_pressed(“move_right”) and position.x < screenWidth:
direction.x += 1
if Input.is_action_pressed(“move_left”) and position.x > 0:
direction.x -= 1
if Input.is_action_pressed(“move_up”) and position.y > 0:
direction.y -= 1
if Input.is_action_pressed(“move_down”) and position.y < screenHeight:
direction.y += 1
if direction.length() > 0:
direction = direction.normalized()
position += direction * speed * delta
#para limite de pantalla
position.x = clamp(position.x, 0, screenWidth)
position.y = clamp(position.y, 0, screenHeight)
#Seleccionar animaciones
if direction.x != 0:
$AnimatedSprite.play("walk")
$AnimatedSprite.flip_v = false
$AnimatedSprite.flip_h = velocity.x < 0
else direction.y != 0:
$AnimatedSprite.play("up")
$AnimatedSprite.flip_v = velocity.y > 0
but i got this error in:
The error was bigger before but it corrects it up to this point and I can’t think of what to do :c