Skip to content

Commit f89de7a

Browse files
committed
Merge pull request godotengine#90960 from TokageItLab/fix-animation-playback-track-seek
Make seeking animation playback track consider internal seeking
2 parents de00cfb + b346e2a commit f89de7a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scene/animation/animation_mixer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
16171617
}
16181618
if (seeked) {
16191619
// Seek.
1620-
int idx = a->track_find_key(i, time, is_external_seeking ? Animation::FIND_MODE_NEAREST : Animation::FIND_MODE_EXACT, true);
1620+
int idx = a->track_find_key(i, time, Animation::FIND_MODE_NEAREST, true);
16211621
if (idx < 0) {
16221622
continue;
16231623
}
@@ -1630,6 +1630,9 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
16301630
double at_anim_pos = 0.0;
16311631
switch (anim->get_loop_mode()) {
16321632
case Animation::LOOP_NONE: {
1633+
if (!is_external_seeking && ((!backward && time >= pos + (double)anim->get_length()) || (backward && time <= pos))) {
1634+
continue; // Do nothing if current time is outside of length when started.
1635+
}
16331636
at_anim_pos = MIN((double)anim->get_length(), time - pos); // Seek to end.
16341637
} break;
16351638
case Animation::LOOP_LINEAR: {
@@ -1641,7 +1644,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
16411644
default:
16421645
break;
16431646
}
1644-
if (player2->is_playing()) {
1647+
if (player2->is_playing() || !is_external_seeking) {
16451648
player2->seek(at_anim_pos, false, p_update_only);
16461649
player2->play(anim_name);
16471650
t->playing = true;

0 commit comments

Comments
 (0)