Backported from godot4: Fix NavigationAgent continues avoidance velocity

Fixes NavigationAgent continues avoidance velocity.
- smix8
c912df9d05
This commit is contained in:
Relintai 2023-09-05 08:01:57 +02:00
parent 5a758b5c1e
commit 397a9e9bcd
2 changed files with 10 additions and 0 deletions

View File

@ -826,6 +826,11 @@ void NavigationAgent2D::update_navigation() {
nav_path_index -= 1; nav_path_index -= 1;
navigation_finished = true; navigation_finished = true;
target_position_submitted = false; 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"); emit_signal("navigation_finished");
break; break;
} }

View File

@ -808,6 +808,11 @@ void NavigationAgent::update_navigation() {
nav_path_index -= 1; nav_path_index -= 1;
navigation_finished = true; navigation_finished = true;
target_position_submitted = false; 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"); emit_signal("navigation_finished");
break; break;
} }