diff options
author | smix8 <52464204+smix8@users.noreply.github.com> | 2023-06-30 00:11:26 +0200 |
---|---|---|
committer | smix8 <52464204+smix8@users.noreply.github.com> | 2023-06-30 00:18:26 +0200 |
commit | 34bc410fb419cb002dbe6cd676f0ff54fab5db9c (patch) | |
tree | 0a615a3d76bd482a96cd02b928d06db0c22a4018 | |
parent | 16dd4e5725a2576ba5765f9f15bccb519b83482c (diff) | |
download | redot-engine-34bc410fb419cb002dbe6cd676f0ff54fab5db9c.tar.gz |
Fix NavigationAgent position not always updating
Fixes NavigationAgent position not always updating.
-rw-r--r-- | scene/2d/navigation_agent_2d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/navigation_agent_3d.cpp | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index 73a801c822..216ee1ce7b 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -258,11 +258,13 @@ void NavigationAgent2D::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { + if (agent_parent && avoidance_enabled) { + NavigationServer2D::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) { - NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position()); NavigationServer2D::get_singleton()->agent_set_velocity(agent, velocity); } } diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 63a2ff5534..99a407ffd3 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -273,11 +273,13 @@ void NavigationAgent3D::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { + if (agent_parent && avoidance_enabled) { + NavigationServer3D::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) { - NavigationServer3D::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; |