Merge pull request #78850 from smix8/navagent_velocity_fix_4.x

Fix NavigationAgent continues avoidance velocity
This commit is contained in:
Rémi Verschelde 2023-07-03 15:26:04 +02:00
commit 9da070fe05
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 10 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}