class_name Character extends CharacterBody2D

@export var speed := 135.0

# Xf2RduncoNU
func _physics_process(_delta: float) -> void:
	var new_direction = Vector2.ZERO
	if Input.is_action_pressed("left"):
		new_direction.x -= 1.0
	if Input.is_action_pressed("right"):
		new_direction.x += 1.0
	if Input.is_action_pressed("up"):
		new_direction.y -= 1.0
	if Input.is_action_pressed("down"):
		new_direction.y += 1.0
	new_direction = new_direction.normalized()
	velocity = new_direction * speed
	
	if velocity == Vector2.ZERO:
		$AnimationTree.get("parameters/playback").travel("idle")
		return
	$AnimationTree.set("parameters/walk/blend_position", new_direction)
	$AnimationTree.set("parameters/idle/blend_position", new_direction)
	$AnimationTree.get("parameters/playback").travel("walk")
	move_and_slide()
