Godot Version
4.4.1
Question
I’m running into two issues related to animations in my 2D project:
- 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.
-
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
- AnimationTree
- Animation bug