Hey all! I'm just getting started with Godot and I have a quick question about animating sprites using an animation tree. I'm trying to get my character sprite to play different movement animations based on which keys are pressed. So far I have walk and idle. I've set up all of my animations correctly in the animation player and I've created the Idle and Walk BlendSpace2D objects in the animation tree, but when I run my game, for some reason only the starting animation plays (which happens to be idle right) and no matter which key I press, the idle right animation never stops playing. So basically I'm able to move my character fluidly around the screen but the sprite animations don't change. Here's my code:
extends CharacterBody2D
@export var move_speed : float = 100
@export var starting_direction : Vector2 = Vector2(0, 1)
@onready var animation_tree = $AnimationTree
func _ready():
update_animation_parameters(starting_direction)
func physics_process(delta):
var input_direction = Vector2(
Input.get_action_strength("right") - Input.get_action_strength("left"),
Input.get_action_strength("down") - Input.get_action_strength("up")
)
update_animation_parameters(input_direction)
velocity = input_direction * move_speed
move_and_slide()
func update_animation_parameters(move_input : Vector2):
if(move_input != Vector2.ZERO):
animation_tree.set("paramters/Walk/blend_position", move_input)
animation_tree.set("paramters/Idle/blend_position", move_input)
I attached a picture of how my animation tree is setup, also.
For reference, here's a link to the video tutorial I'm using:
Any help would be greatly appreciated!