How to find out if an Animation in an AnimationTree has finished

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

Hi,

I’m trying to find out when an Animation in an AnimationTree has finished.

The idea is that when my character attacks I want him to stop moving and only resume moving once the attack animation has finished. In an AnimationPlayer I could use the Signal animation_finished() but this does not exist for the AnimationTree which I am using to control my characters evolving state machine.

I can find out which animation is playing in the AnimationTree using .get_current_node() and I can find out if the AnimationTree itself is_playing() an animation but I can’t seem to find a way to know when a specific animation in the AnimationTree has finished so that I can then execute some code.

The only thing I can think of is setting a Timer but I was wondering if there was a simpler solution?

Thanks for any help!

:bust_in_silhouette: Reply From: Thakee Nathees

try this: https://forum.godotengine.org/18641/how-to-call-function-on-a-certain-frame-in-animation-player

Thank you! Works a treat!

Mogulweasel | 2020-05-02 11:02

The issue with this is that you need to make a new track for every animation you want to know that is finished.

blurrred | 2021-06-09 18:36