Hello, im trying to make multiple idle animations for my player, and other entities aswell based on previously moving direction, defaulting to idleDown, so my script is like this:
extends CharacterBody2D
@export var speed: int = 150
@onready var animations = $AnimationPlayer
func handleInput():
var moveDirection = Input.get_vector("ui_right", "ui_left", "ui_up", "ui_down")
velocity = moveDirection*speed
func updateAnimation():
var direction = ""
var walk = "walk"
var idle = "idle"
var animation = ""
if velocity.x < 0: direction = "Left"
elif velocity.x > 0: direction = "Right"
elif velocity.y < 0: direction = "Up"
elif velocity.y > 0: direction = "Down"
if velocity.x == 0 and velocity.y == 0:
animation = idle + direction
else:
animation = walk + direction
animations.play(animation)
func _physics_process(delta):
handleInput()
move_and_slide()
updateAnimation()
But well, its not working, if i default value direction to Down, it will use idleDown to reset animations, but other idle animations do not work, im quite new and dont know much but how do i do this