So I’ve been following a bunch of tutorials on youtube about creating movement and animating sprites and all the great gamedev things, and I finally found a tutorial that was pretty simple to follow and easy to understand (linked below if anybody wants it). This tutorial gave me the following lines of code, alongside an animation player, animation tree, and sprite2d all under a CharacterBody2D node.
extends CharacterBody2D
@export var SPEED = 10000 @onready var anim_tree = get_node(“AnimationTree”)
My problem is that when I open up the debug window (I think that’s what it’s called) and do the normal inputs to test everything, the only animation that plays is my left facing idle and run (i haven’t created the inputs for attacking yet).
It looks like you’re facing an issue with the movement input affecting only one direction (left), which could be due to a couple of things in your code setup.
Animation Tree Setup: Since you’re using a BlendSpace2D, it’s important to make sure that your blend points (for idle and run) are configured correctly for each direction (up, down, left, right). If the blend points only cover left and idle, the other directions won’t animate properly.You’re setting the blend_position for idle, run, and attack in the same way. Since you’re only dealing with idle and run animations (you haven’t set up attack yet), just set the blend_position for the current animation:
code: if input_vector == Vector2.ZERO:
anim_tree.get(“parameters/playback”).travel(“idle”)
anim_tree.set(“parameters/idle/BlendSpace2D/blend_position”, input_vector)
else:
anim_tree.get(“parameters/playback”).travel(“run”)
anim_tree.set(“parameters/run/BlendSpace2D/blend_position”, input_vector)
Do try this…snippet…code:
extends CharacterBody2D
@export var SPEED = 10000 @onready var anim_tree = get_node(“AnimationTree”)