浏览代码

Fix AnimationPlayer jumping to the beggining after ending on editor.

Luiz 6 年之前
父节点
当前提交
e27bbb075a
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      scene/animation/animation_player.cpp

+ 8 - 4
scene/animation/animation_player.cpp

@@ -938,7 +938,6 @@ void AnimationPlayer::_animation_process(float p_delta) {
 			} else {
 				//stop();
 				playing = false;
-				playback.current.pos = 0;
 				_set_process(false);
 				if (end_notify)
 					emit_signal(SceneStringNames::get_singleton()->animation_finished, playback.assigned);
@@ -1196,9 +1195,14 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
 
 	if (c.assigned != name) { // reset
 		c.current.pos = p_from_end ? c.current.from->animation->get_length() : 0;
-	} else if (p_from_end && c.current.pos == 0) {
-		// Animation reset BUT played backwards, set position to the end
-		c.current.pos = c.current.from->animation->get_length();
+	} else {
+		if (p_from_end && c.current.pos == 0) {
+			// Animation reset BUT played backwards, set position to the end
+			c.current.pos = c.current.from->animation->get_length();
+		} else if (!p_from_end && c.current.pos == c.current.from->animation->get_length()) {
+			// Animation resumed but already ended, set position to the beggining
+			c.current.pos = 0;
+		}
 	}
 
 	c.current.speed_scale = p_custom_scale;