diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index d101cac4ebd..8dca7b52970 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -151,6 +151,10 @@ void NavigationAgent2D::_notification(int p_what) { set_agent_parent(get_parent()); set_physics_process_internal(true); + if (agent_parent && avoidance_enabled) { + NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position()); + } + #ifdef DEBUG_ENABLED if (NavigationServer2D::get_singleton()->get_debug_enabled()) { debug_path_dirty = true; diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp index 2366cb696ef..a23de5646ac 100644 --- a/scene/2d/navigation_obstacle_2d.cpp +++ b/scene/2d/navigation_obstacle_2d.cpp @@ -63,6 +63,9 @@ void NavigationObstacle2D::_notification(int p_what) { case NOTIFICATION_POST_ENTER_TREE: { set_agent_parent(get_parent()); set_physics_process_internal(true); + if (parent_node2d && parent_node2d->is_inside_tree()) { + NavigationServer2D::get_singleton()->agent_set_position(agent, parent_node2d->get_global_position()); + } } break; case NOTIFICATION_EXIT_TREE: { diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 7d404ffa075..bd574257777 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -154,6 +154,10 @@ void NavigationAgent3D::_notification(int p_what) { set_agent_parent(get_parent()); set_physics_process_internal(true); + if (agent_parent && avoidance_enabled) { + NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position()); + } + #ifdef DEBUG_ENABLED if (NavigationServer3D::get_singleton()->get_debug_enabled()) { debug_path_dirty = true; diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index 14d93fb0e03..66d14538d7a 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -62,6 +62,9 @@ void NavigationObstacle3D::_notification(int p_what) { case NOTIFICATION_POST_ENTER_TREE: { set_agent_parent(get_parent()); set_physics_process_internal(true); + if (parent_node3d && parent_node3d->is_inside_tree()) { + NavigationServer3D::get_singleton()->agent_set_position(agent, parent_node3d->get_global_position()); + } } break; case NOTIFICATION_EXIT_TREE: {