Hey all, so i'm a bit new to godot and trying to figure out how to both have a good walk and idle animation, but mainly when a player stops in a certain direction (let's say facing the right) I would like to play an idle animation of facing right. I feel like i've watched a million videos and tried several methods but they either don't work at all or are for an older version and no longer work as well. I'm currently trying a method where the animation tree is utilized but it just won't work when idling, only for walking. Thanks for any suggestions!
`extends CharacterBody2D
@export var speed: int = 80
@onready var animation_tree : AnimationTree = $AnimationTree
var direction : Vector2 = Vector2.ZERO
func _ready():
animation_tree.active = true
func _process(delta):
update_animation_parameters()
func _physics_process(delta):
direction = Input.get_vector("left", "right", "up", "down").normalized()
if direction:
velocity = direction * speed
else:
velocity = Vector2.ZERO
move_and_slide()
func update_animation_parameters():
if (velocity == Vector2.ZERO):
animation_tree["parameters/conditions/idle"] = true
animation_tree["parameters/conditions/is_moving"] = false
else:
animation_tree["parameters/conditions/idle"] = false
animation_tree["parameters/conditions/is_moving"] = true
if (direction != Vector2.ZERO):
animation_tree["parameters/Idle/blend_position"] = direction
animation_tree["parameters/Walk/blend_position"] = direction`