You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #110508 from Olle-Lukowski/fix/emit-anim-finished
Ensure the AnimationPlayer emits animation_finished for every animation
This commit is contained in:
@@ -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<List<Blend>::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()));
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
private:
|
||||
AHashMap<StringName, StringName> animation_next_set; // For auto advance.
|
||||
|
||||
StringName finished_anim;
|
||||
|
||||
float speed_scale = 1.0;
|
||||
double default_blend_time = 0.0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user