瀏覽代碼

Merge pull request #12898 from RandomShaper/improve-anim-loop

Change AnimationPlayer looping logic
Rémi Verschelde 7 年之前
父節點
當前提交
bd775aa0bd
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      scene/animation/animation_player.cpp

+ 8 - 1
scene/animation/animation_player.cpp

@@ -545,7 +545,14 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
 
 	} else {
 
-		next_pos = Math::fposmod(next_pos, len);
+		float looped_next_pos = Math::fposmod(next_pos, len);
+		if (looped_next_pos == 0 && next_pos != 0) {
+			// Loop multiples of the length to it, rather than 0
+			// so state at time=length is previewable in the editor
+			next_pos = len;
+		} else {
+			next_pos = looped_next_pos;
+		}
 	}
 
 	cd.pos = next_pos;