Godot Version
extends CharacterBody2D
var speed = 250
@onready var animTree: AnimationTree = $AnimationTree
var input : Vector2 = Vector2.ZERO
func _ready():
animTree.active = true
func _process(delta):
update_anim_parameters()
func _physics_process(delta):
handle_movement()
func handle_movement():
input = Input.get_vector(“ui_left”, “ui_right”, “ui_up”, “ui_down”).normalized()
if input:
velocity = input * speed
else:
velocity = Vector2.ZERO
move_and_slide()
func update_anim_parameters():
if (velocity == Vector2.ZERO):
animTree[“parameters/conditions/Idle”] = true
animTree[“parameters/conditions/Run”] = false
else:
animTree[“parameters/conditions/Idle”] = false
animTree[“parameters/conditions/Run”] = true
if (Input.is_action_just_pressed("ui_mouse_left")):
animTree["parameters/conditions/Attack"] = true
else:
animTree["parameters/conditions/Attack"] = false
animTree["parameters/Idle/blend_position"] = input
animTree["parameters/Run/blend_position"] = input
animTree["parameters/Attack_side_1/blend_position"] = input
Question
Hi I’m new to game development and I’m attempting to make a game. I’m using an animation tree with a sprite 2d and animation player. It’s all been set up correctly to my knowledge The issue I’m having is, I have a sprite sheet free asset I love but it has only one direction for idle and run(technically 2 with flip_h) but it has 4 directions for attacks. So I have implemented a state machine into the anim tree and I did blend space 1d for idle and run, separately, but 2dblend space for attacks and for whatever reason I idle only left. I have flip_h in the animation player for left and right and have it turned off and keyed in for idle right and it still doesnt work.