Godot Version
4.7
Question
Hello, I’m getting started with Godot and made a playground to get to understand basics of game development with Godot. I created a character with animations imported from Mixamo and was able to display properly IDLE, RUN, ATTACK, now I tried to add a run animation so the character don’t snap to the new direction but now my other animations are not being show. I see that the blend values go close to 1 for the nodes but I’m stuck moving in IDLE and since I’m not firing the attack animation if I click (attack) the signal for finishing the attack animation is not being fired resulting in a loop that prevents for any other input.
I’'ll provide my player code, my animationTree and I don’t know what else is useful to resolve this like I said I’m totally new to Godot and to game development. Thanks
Animation Tree
Animation Tree Parameters
My player script, I created an Enum that used inside of function handle_animations() updated the run_val and turn_val to be shared with update_tree() there’s a bunch of commented print’s that I was using to debug but the one that is throwing me off is that I see the values coming close to one in this one print("run val: %s, turn val: %s" % [run_val, turn_val])
class_name Player
extends CharacterBody3D
@onready var animation_player: AnimationPlayer = $manniqui/AnimationPlayer
@onready var animation_tree: AnimationTree = $AnimationTree
@export var acceleration: float
@export var walk_speed: float
@export var run_speed: float
@export var camera_position : Node3D
@export var is_running : bool = false
@export var blend_speed := 2
@export var TURN_THRESHOLD : float = 0.7
@export var turn_speed : float = 0.7
var horizontal_velocity := Vector3.ZERO
var animation_is_stopped : bool = false
var input_dir := Vector2.ZERO
var run_val := 0.0
var turn_val := 0.0
var attack_val:= 0.0
enum {IDLE, RUN, TURN}
var curAnim = IDLE
var is_attacking : bool = false
func handle_animations(delta : float) -> void:
match curAnim:
IDLE:
run_val = lerpf(run_val, 0, blend_speed * delta)
turn_val = lerpf(turn_val, 0, blend_speed * delta)
TURN:
#print("----------")
#print("turning at %s", lerpf(turn_val, 1, blend_speed * delta))
#print("----------")
run_val = lerpf(run_val, 0, blend_speed * delta)
turn_val = lerpf(turn_val, 1, blend_speed * delta)
RUN:
#print("----------")
#print("running at %s", lerpf(run_val, 1, blend_speed * delta))
#print("----------")
run_val = lerpf(run_val, 1, blend_speed * delta)
turn_val = lerpf(turn_val, 0, blend_speed * delta)
func update_tree() -> void:
print("run val: %s, turn val: %s" % [run_val, turn_val])
animation_tree.set("parameters/Run/blend_amount", run_val)
animation_tree.set("parameters/Turn/blend_amount", turn_val)
func _on_animation_finished(anim_name: StringName) -> void:
if anim_name == "sword":
is_attacking = false
func _ready() -> void:
animation_tree.animation_finished.connect(_on_animation_finished)
func _process(delta: float) -> void:
input_dir = Input.get_vector("strafe_right", "strafe_left", "backward", "forward")
func _physics_process(delta: float) -> void:
handle_animations(delta)
update_tree()
if is_attacking:
print("entered attacking")
velocity.x = move_toward(velocity.x, 0, acceleration * delta)
velocity.z = move_toward(velocity.z, 0, acceleration * delta)
move_and_slide()
return
var move_dir := Vector3(input_dir.x, 0, input_dir.y)
#print("move_dir: ", move_dir)
var target_speed := run_speed if Input.is_action_pressed("run") else walk_speed
var desired_velocity := move_dir * target_speed
if move_dir == Vector3.ZERO:
velocity.x = move_toward(velocity.x, 0, acceleration * delta)
velocity.z = move_toward(velocity.z, 0, acceleration * delta)
curAnim = IDLE
else:
var facing := -global_transform.basis.z
var dot := facing.dot(move_dir.normalized())
#print("dot: ",dot)
# Smooth rotation — gives the turn animation time to play
var target_angle := atan2(-move_dir.x, -move_dir.z)
rotation.y = lerp_angle(rotation.y, target_angle, turn_speed * delta)
if dot < TURN_THRESHOLD:
curAnim = TURN
# Hold still while turning
velocity.x = move_toward(velocity.x, 0, acceleration * delta)
velocity.z = move_toward(velocity.z, 0, acceleration * delta)
else:
curAnim = RUN
velocity.x = move_toward(velocity.x, desired_velocity.x, acceleration * delta)
velocity.z = move_toward(velocity.z, desired_velocity.z, acceleration * delta)
horizontal_velocity = Vector3(velocity.x, 0, velocity.z)
move_and_slide()
func _input(event: InputEvent) -> void:
if event.is_action_pressed("attack"):
print("entered attacking")
is_attacking = true
animation_tree.set("parameters/Attack/request",
AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
Hope that you can help me, I’m Argentinian so sorry if my wording in english is confusing.
Cheers, thanks in advance.

