diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index d00ef800da4..eea2ed3a948 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -277,6 +277,9 @@ void AnimationPlayer::_blend_playback_data(double p_delta, bool p_started) { // Finally, if not end the animation, do blending. if (end_reached) { playback.blend.clear(); + if (end_notify) { + finished_anim = playback.assigned; + } return; } List::Element *> to_erase; @@ -306,6 +309,8 @@ bool AnimationPlayer::_blend_pre_process(double p_delta, int p_track_count, cons end_reached = false; end_notify = false; + finished_anim = StringName(); + bool started = playback.started; // The animation may be changed during process, so it is safer that the state is changed before process. if (playback.started) { playback.started = false; @@ -326,6 +331,10 @@ void AnimationPlayer::_blend_capture(double p_delta) { } void AnimationPlayer::_blend_post_process() { + if (!finished_anim.is_empty()) { + emit_signal(SceneStringName(animation_finished), finished_anim); + } + if (end_reached) { // If the method track changes current animation, the animation is not finished. if (tmp_from == playback.current.from->animation->get_instance_id()) { @@ -342,7 +351,6 @@ void AnimationPlayer::_blend_post_process() { playing = false; _set_process(false); if (end_notify) { - emit_signal(SceneStringName(animation_finished), playback.assigned); emit_signal(SNAME("current_animation_changed"), ""); if (movie_quit_on_finish && OS::get_singleton()->has_feature("movie")) { print_line(vformat("Movie Maker mode is enabled. Quitting on animation finish as requested by: %s", get_path())); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 94fee7b0993..4aa2411d0a2 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -52,6 +52,8 @@ public: private: AHashMap animation_next_set; // For auto advance. + StringName finished_anim; + float speed_scale = 1.0; double default_blend_time = 0.0;