extends CharacterBody2D @onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D var speed = 200 # speed in pixels/sec func _physics_process(delta): var direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") velocity = direction * speed if direction.x < 0: animated_sprite_2d.play("walk_left") if direction.x > 0: animated_sprite_2d.play("walk_right") if direction.y < 0: animated_sprite_2d.play("walk_up") if direction.y > 0: animated_sprite_2d.play("walk_down") if direction.x == 0 and direction.y == 0: animated_sprite_2d.play("idle") move_and_slide()