Ported from godot4: Fix NavigationAgent position not always updating

Fixes NavigationAgent position not always updating.
- smix8
34bc410fb4
This commit is contained in:
Relintai 2023-09-04 17:38:32 +02:00
parent 8485b37515
commit e2fd645a42
2 changed files with 8 additions and 2 deletions

View File

@ -255,11 +255,14 @@ void NavigationAgent2D::_notification(int p_what) {
#endif // DEBUG_ENABLED
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent && avoidance_enabled) {
Navigation2DServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_position());
}
if (agent_parent && target_position_submitted) {
if (velocity_submitted) {
velocity_submitted = false;
if (avoidance_enabled) {
Navigation2DServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_position());
Navigation2DServer::get_singleton()->agent_set_velocity(agent, velocity);
}
}

View File

@ -267,11 +267,14 @@ void NavigationAgent::_notification(int p_what) {
}
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent && avoidance_enabled) {
NavigationServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
}
if (agent_parent && target_position_submitted) {
if (velocity_submitted) {
velocity_submitted = false;
if (avoidance_enabled) {
NavigationServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
if (!use_3d_avoidance) {
stored_y_velocity = velocity.y;
velocity.y = 0.0;