Skip to content

Commit cc87b83

Browse files
committed
Allow animations to be restarted from vanilla animation player.
1 parent bd32776 commit cc87b83

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

scene/animation/animation_player.cpp

+4-18
Original file line numberDiff line numberDiff line change
@@ -502,21 +502,9 @@ void AnimationPlayer::play_section(const StringName &p_name, double p_start_time
502502
playback_queue.clear();
503503
}
504504

505-
if (c.assigned != name) { // Reset.
506-
c.current.pos = p_from_end ? end : start;
507-
c.assigned = name;
508-
emit_signal(SNAME("current_animation_changed"), c.assigned);
509-
} else {
510-
if (p_from_end && Math::is_equal_approx(c.current.pos, start)) {
511-
// Animation reset but played backwards, set position to the end.
512-
seek_internal(end, true, true, true);
513-
} else if (!p_from_end && Math::is_equal_approx(c.current.pos, end)) {
514-
// Animation resumed but already ended, set position to the beginning.
515-
seek_internal(start, true, true, true);
516-
} else if (playing) {
517-
return;
518-
}
519-
}
505+
c.current.pos = p_from_end ? end : start;
506+
c.assigned = name;
507+
emit_signal(SNAME("current_animation_changed"), c.assigned);
520508

521509
c.seeked = false;
522510
c.started = true;
@@ -586,11 +574,9 @@ void AnimationPlayer::set_current_animation(const String &p_animation) {
586574
stop();
587575
} else if (!is_playing()) {
588576
play(p_animation);
589-
} else if (playback.assigned != p_animation) {
577+
} else {
590578
float speed = playback.current.speed_scale;
591579
play(p_animation, -1.0, speed, signbit(speed));
592-
} else {
593-
// Same animation, do not replay from start.
594580
}
595581
}
596582

0 commit comments

Comments
 (0)