Skip to content

Commit b51320f

Browse files
committed
Merge pull request godotengine#112450 from TokageItLab/fix-oneshot-reset
Fix NodeOneShot doesn't reset correctly
2 parents 87279f0 + 2f029bc commit b51320f

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

scene/animation/animation_blend_tree.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ AnimationNode::NodeTimeInfo AnimationNodeOneShot::_process(const AnimationMixer:
550550
set_parameter(request, ONE_SHOT_REQUEST_NONE);
551551

552552
bool is_shooting = true;
553-
bool clear_remaining_fade = false;
554553
bool is_fading_out = cur_active == true && cur_internal_active == false;
555554

556555
double p_time = p_playback_info.time;
@@ -559,15 +558,25 @@ AnimationNode::NodeTimeInfo AnimationNodeOneShot::_process(const AnimationMixer:
559558
bool p_seek = p_playback_info.seeked;
560559
bool p_is_external_seeking = p_playback_info.is_external_seeking;
561560

562-
if (Math::is_zero_approx(p_time) && p_seek && !p_is_external_seeking) {
563-
clear_remaining_fade = true; // Reset occurs.
561+
bool do_start = cur_request == ONE_SHOT_REQUEST_FIRE;
562+
563+
bool is_reset = Math::is_zero_approx(p_time) && p_seek && !p_is_external_seeking;
564+
if (is_reset && cur_internal_active) {
565+
do_start = true;
564566
}
565567

566-
bool do_start = cur_request == ONE_SHOT_REQUEST_FIRE;
567-
if (cur_request == ONE_SHOT_REQUEST_ABORT) {
568+
bool is_abort = cur_request == ONE_SHOT_REQUEST_ABORT;
569+
if (is_reset && is_fading_out) {
570+
is_abort = true;
571+
}
572+
573+
if (is_abort) {
568574
set_parameter(internal_active, false);
569575
set_parameter(active, false);
570576
set_parameter(time_to_restart, -1);
577+
set_parameter(fade_out_remaining, 0);
578+
cur_fade_out_remaining = 0;
579+
is_fading_out = false;
571580
is_shooting = false;
572581
} else if (cur_request == ONE_SHOT_REQUEST_FADE_OUT && !is_fading_out) { // If fading, keep current fade.
573582
if (cur_active) {
@@ -596,17 +605,6 @@ AnimationNode::NodeTimeInfo AnimationNodeOneShot::_process(const AnimationMixer:
596605

597606
bool os_seek = p_seek;
598607

599-
if (clear_remaining_fade) {
600-
os_seek = false;
601-
cur_fade_out_remaining = 0;
602-
set_parameter(fade_out_remaining, 0);
603-
if (is_fading_out) {
604-
is_fading_out = false;
605-
set_parameter(internal_active, false);
606-
set_parameter(active, false);
607-
}
608-
}
609-
610608
if (!is_shooting) {
611609
AnimationMixer::PlaybackInfo pi = p_playback_info;
612610
pi.weight = 1.0;

0 commit comments

Comments
 (0)