浏览代码

Fix NavigationAgent continues avoidance velocity

Fixes NavigationAgent continues avoidance velocity.
smix8 2 年之前
父节点
当前提交
c912df9d05
共有 2 个文件被更改,包括 10 次插入0 次删除
  1. 5 0
      scene/2d/navigation_agent_2d.cpp
  2. 5 0
      scene/3d/navigation_agent_3d.cpp

+ 5 - 0
scene/2d/navigation_agent_2d.cpp

@@ -755,6 +755,11 @@ void NavigationAgent2D::update_navigation() {
 				navigation_path_index -= 1;
 				navigation_finished = true;
 				target_position_submitted = false;
+				if (avoidance_enabled) {
+					NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position());
+					NavigationServer2D::get_singleton()->agent_set_velocity(agent, Vector2(0.0, 0.0));
+					NavigationServer2D::get_singleton()->agent_set_velocity_forced(agent, Vector2(0.0, 0.0));
+				}
 				emit_signal(SNAME("navigation_finished"));
 				break;
 			}

+ 5 - 0
scene/3d/navigation_agent_3d.cpp

@@ -801,6 +801,11 @@ void NavigationAgent3D::update_navigation() {
 				navigation_path_index -= 1;
 				navigation_finished = true;
 				target_position_submitted = false;
+				if (avoidance_enabled) {
+					NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
+					NavigationServer3D::get_singleton()->agent_set_velocity(agent, Vector3(0.0, 0.0, 0.0));
+					NavigationServer3D::get_singleton()->agent_set_velocity_forced(agent, Vector3(0.0, 0.0, 0.0));
+				}
 				emit_signal(SNAME("navigation_finished"));
 				break;
 			}