animation_changed is never fired by my AnimationPlayer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jedesjardins

I’m trying to make a class AnimationChain that will play a list of Animations in an AnimationPlayer back to back. This part is working fine. However, I also want it to detect if another animation is played on the AnimationPlayer that interrupts the AnimationChain.

i.e. I start a chain of animations like [“idledown”, “idleright”, “idleleft”] with the AnimationChain and then somewhere else in code I call“idleup”) while the AnimationChain is still running.

The problem is that I tried to connect the "animation_changed" signal to a function on the AnimationChain class and it is never fired. I tried the same with "animation_started" and it fires as usual.

Here is the code for AnimationChain:

extends Node

class_name AnimationChain

signal finished

var animation_player: AnimationPlayer
var is_interrupted = false
var is_playing = false

func _init(ap: AnimationPlayer):
    animation_player = ap

    var err = animation_player.connect("animation_changed", self, "interrupted")
        if err:
            print("Error initializing AnimationChain")

    err = animation_player.connect("animation_started", self, "started")
    if err:
	print("Error initializing AnimationChain")

func started(_new_name: String):

func interrupted(old_name: String, new_name: String):
    print("Interrupted ", old_name, "with ", new_name)
    is_interrupted = true

func run(animations: PoolStringArray, _durations = null):
    is_playing = true
    is_interrupted = false
    if animation_player.current_animation == animations[0]:, true)

    for i in range(animations.size()):
        var animation_name = animations[i]

        yield(animation_player, "animation_finished")
        if is_interrupted:
            print("Animation chain interrupted, not finishing!")
            is_playing = false

        is_playing = false

And I start the AnimationChain with:["idle_down", "idle_down_right", "idle_down_left"])

then interrupt it a few frames later with"idle_up")

This animates exactly as I expect it to. The started function is called at the beginning of each animation in the chain and when I interrupt with the “idleup” animation, but the interrupt/animation_changed function never is called.

Maybe I’m mistaken when the animation_changed signal is called? Thanks for any suggestions/help!

:bust_in_silhouette: Reply From: jedesjardins

Never mind, I misunderstood when animation_changed would fire.

This link: animation_changed signal is broken · Issue #3520 · godotengine/godot · GitHub mentions the animation_changed signal is only “meant to be called when a queued animation starts”. Given I’m not queuing animations this doesn’t apply to me