AnimationTree issues: empty animation error and animations not playing

Godot Version

4.4.1

Question

I’m running into two issues related to animations in my 2D project:

  1. Animation ‘’ doesn’t exist error

Right after I run the scene, I get this error in the console:

E 0:00:01:069   get_frame_count: Animation '' doesn't exist.
  <Erro C++>    Condition "!E" is true. Returning: 0`
  <Origem C++>  scene/resources/sprite_frames.cpp:71 @ get_frame_count()

I don’t have any animations with an empty name in my project, so I’m not sure why this is showing up.

  1. AnimationTree not playing animations correctly

    The second issue is that my character’s animations aren’t behaving as expected:

    • The movement speed feels way too fast.
    • The animations don’t always play, or they seem stuck.
    • Even if I change the time scale (globally or for the animations), it doesn’t fix the problem.

    Here’s a simplified version of the player script:

extends CharacterBody2D

var play_animation
var move_speed: int = 100
var last_direction := Vector2(0, -1)

var move_horizontal: bool = false
var move_vertical: bool = false
var weapon_equipped: bool = false

var bullet_scene = preload("res://Scenes/Weapons/Shotgun/shotgun_bullet.tscn")
var animation_tree: AnimationTree

func _ready() -> void:
	animation_tree = $Animation/AnimationTree
	play_animation = animation_tree.get("parameters/playback")

func _physics_process(_delta: float) -> void:
	player_movement()
	player_animation()
	move_and_slide()
	
func player_movement():
	var player_move: Vector2 = Input.get_vector("move_left", "move_right", "move_up", "move_down")
	velocity = player_move * move_speed

func player_animation():
	var is_idle = !velocity

	if !is_idle:
		last_direction = velocity.normalized()
	animation_tree.set("parameters/walk/blend_position", last_direction)
	animation_tree.set("parameters/idle/blend_position", last_direction)

Visual References

  1. AnimationTree
  2. Animation bug
1 Like

Do you have any code to travel between different states in the AnimationTree, like play_animation.travel("idle")?

The error comes from SpriteFrames which points to an AnimatedSprite2D I don’t think it’s possible to add an animation with no name in the editor. Are you doing it in code?

The state machine transitions AnimationNodeStateMachineTransition.advance_mode are set to Auto Did you correctly set their AnimationNodeStateMachineTransition.advance_condition or AnimationNodeStateMachineTransition.advance_expression correctly? Did you correctly set up the AnimationTree.advance_expression_base_node to point to the node where the conditions or expressions are evaluated?

If you are manually calling AnimationNodeStateMachinePlayback.travel() then change the transitions’ mode to Enabled

Are you doing it in code?

No. I’ve already gone through everything, but I just can’t pinpoint where this error is coming from.

I have already followed all the recommendations. I set the advance_expression_base_node correctly, defined the advance_conditions for each transition, and double-checked everything. Nothing has worked so far.