diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-30 17:34:48 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-30 17:34:48 +0100 |
commit | 19c2c54ee52c6de1351792778cfa03afa9f2ecb8 (patch) | |
tree | f6630d5498a0a9803ab8ff1a3d197b833c5feea5 | |
parent | 17a85973559fae0cd2c33d13c4b53f16cf7419ba (diff) | |
parent | f8d529a232cd1aac879fe94d22ef7ec5edcf662d (diff) |
Merge pull request #72380 from TokageItLab/noanim-seek
Allow `seek()` without assigned animation in `AnimationPlayer`
-rw-r--r-- | scene/animation/animation_player.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 1b7615befa..2e25d685d6 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1816,15 +1816,18 @@ float AnimationPlayer::get_playing_speed() const { } void AnimationPlayer::seek(double p_time, bool p_update) { + playback.current.pos = p_time; + if (!playback.current.from) { if (playback.assigned) { ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", playback.assigned)); playback.current.from = &animation_set[playback.assigned]; } - ERR_FAIL_COND(!playback.current.from); + if (!playback.current.from) { + return; // There is no animation. + } } - playback.current.pos = p_time; playback.seeked = true; if (p_update) { _animation_process(0); @@ -1832,20 +1835,22 @@ void AnimationPlayer::seek(double p_time, bool p_update) { } void AnimationPlayer::seek_delta(double p_time, double p_delta) { + playback.current.pos = p_time - p_delta; + if (!playback.current.from) { if (playback.assigned) { ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", playback.assigned)); playback.current.from = &animation_set[playback.assigned]; } - ERR_FAIL_COND(!playback.current.from); + if (!playback.current.from) { + return; // There is no animation. + } } - playback.current.pos = p_time - p_delta; if (speed_scale != 0.0) { p_delta /= speed_scale; } _animation_process(p_delta); - //playback.current.pos=p_time; } bool AnimationPlayer::is_valid() const { |