summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-10-06 12:53:09 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-10-06 12:53:09 +0200
commit249e724835be7852297a7d59b6ab739064460e41 (patch)
tree8a11bcc8c98a313adab928169fdeb90bb3eae94a
parentc05f521e16eabb4dc5809d7f41f01af833a32be8 (diff)
parentd46c962f1850ee8aca933d147a1997156c69069d (diff)
downloadredot-engine-249e724835be7852297a7d59b6ab739064460e41.tar.gz
Merge pull request #82898 from TokageItLab/fix-unwanted-start-in-animation-player
Fix `AnimationPlayer::play()` process unwanted start between the same animations
-rw-r--r--scene/animation/animation_player.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index a886831fdb..2d4f2cbceb 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -415,9 +415,16 @@ void AnimationPlayer::play(const StringName &p_name, double p_custom_blend, floa
}
c.current.from = &animation_set[name];
+ c.current.speed_scale = p_custom_scale;
+
+ if (!end_reached) {
+ playback_queue.clear();
+ }
if (c.assigned != name) { // Reset.
c.current.pos = p_from_end ? c.current.from->animation->get_length() : 0;
+ c.assigned = name;
+ emit_signal(SNAME("current_animation_changed"), c.assigned);
} else {
if (p_from_end && c.current.pos == 0) {
// Animation reset but played backwards, set position to the end.
@@ -425,18 +432,14 @@ void AnimationPlayer::play(const StringName &p_name, double p_custom_blend, floa
} else if (!p_from_end && c.current.pos == c.current.from->animation->get_length()) {
// Animation resumed but already ended, set position to the beginning.
c.current.pos = 0;
+ } else if (playing) {
+ return;
}
}
- c.current.speed_scale = p_custom_scale;
- c.assigned = name;
- emit_signal(SNAME("current_animation_changed"), c.assigned);
c.seeked = false;
c.started = true;
- if (!end_reached) {
- playback_queue.clear();
- }
_set_process(true); // Always process when starting an animation.
playing = true;