From 6f3b1fac5707fb62924f3c777a5b3c5a8f6715d3 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 5 Sep 2023 09:01:44 +0200 Subject: [PATCH] Simplify some logic in NavigationAgent2D. --- scene/2d/navigation_agent_2d.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index b7d8e7701..1f2583057 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -373,14 +373,9 @@ void NavigationAgent2D::set_agent_parent(Node *p_agent_parent) { if (Object::cast_to(p_agent_parent) != nullptr) { // place agent on navigation map first or else the RVO agent callback creation fails silently later agent_parent = Object::cast_to(p_agent_parent); - if (map_override.is_valid()) { - Navigation2DServer::get_singleton()->agent_set_map(get_rid(), map_override); - } else if (navigation != nullptr) { - Navigation2DServer::get_singleton()->agent_set_map(get_rid(), navigation->get_rid()); - } else { - // no navigation node found in parent nodes, use default navigation map from world resource - Navigation2DServer::get_singleton()->agent_set_map(get_rid(), agent_parent->get_world_2d()->get_navigation_map()); - } + + Navigation2DServer::get_singleton()->agent_set_map(get_rid(), get_navigation_map()); + // create new avoidance callback if enabled Navigation2DServer::get_singleton()->agent_set_avoidance_callback(agent, get_instance_id(), "_avoidance_done"); } else {