From 397a9e9bcdaa0dcf8353489999eb67886d280a44 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 5 Sep 2023 08:01:57 +0200 Subject: [PATCH] Backported from godot4: Fix NavigationAgent continues avoidance velocity Fixes NavigationAgent continues avoidance velocity. - smix8 https://github.com/godotengine/godot/commit/c912df9d0591a7abcab9d0eab5fac80c28117e9f --- scene/2d/navigation_agent_2d.cpp | 5 +++++ scene/3d/navigation_agent.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index c69839603..b7d8e7701 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -826,6 +826,11 @@ void NavigationAgent2D::update_navigation() { nav_path_index -= 1; navigation_finished = true; target_position_submitted = false; + if (avoidance_enabled) { + Navigation2DServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_position()); + Navigation2DServer::get_singleton()->agent_set_velocity(agent, Vector2(0.0, 0.0)); + Navigation2DServer::get_singleton()->agent_set_velocity_forced(agent, Vector2(0.0, 0.0)); + } emit_signal("navigation_finished"); break; } diff --git a/scene/3d/navigation_agent.cpp b/scene/3d/navigation_agent.cpp index 1c5b762de..1c2758abf 100644 --- a/scene/3d/navigation_agent.cpp +++ b/scene/3d/navigation_agent.cpp @@ -808,6 +808,11 @@ void NavigationAgent::update_navigation() { nav_path_index -= 1; navigation_finished = true; target_position_submitted = false; + if (avoidance_enabled) { + NavigationServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin); + NavigationServer::get_singleton()->agent_set_velocity(agent, Vector3(0.0, 0.0, 0.0)); + NavigationServer::get_singleton()->agent_set_velocity_forced(agent, Vector3(0.0, 0.0, 0.0)); + } emit_signal("navigation_finished"); break; }