diff --git a/main/main.cpp b/main/main.cpp index 12df1befa..da589d25c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -221,14 +221,31 @@ void finalize_physics() { void initialize_navigation_server() { ERR_FAIL_COND(navigation_server != nullptr); - navigation_server = NavigationServerManager::new_default_server(); - navigation_2d_server = Navigation2DServerManager::new_default_server(); + ERR_FAIL_COND(navigation_2d_server != nullptr); + + /// 3D Navigation Server + navigation_server = NavigationServerManager::new_server(ProjectSettings::get_singleton()->get(NavigationServerManager::setting_property_name)); + if (!navigation_server) { + // Navigation server not found, Use the default physics + navigation_server = NavigationServerManager::new_default_server(); + } + ERR_FAIL_COND(!navigation_server); + //physics_server->init(); + + /// 2D Navigation server + navigation_2d_server = Navigation2DServerManager::new_server(ProjectSettings::get_singleton()->get(Navigation2DServerManager::setting_property_name)); + if (!navigation_2d_server) { + // Navigation server not found, Use the default physics + navigation_2d_server = Navigation2DServerManager::new_default_server(); + } + ERR_FAIL_COND(!navigation_2d_server); + //navigation_2d_server->init(); } void finalize_navigation_server() { memdelete(navigation_server); navigation_server = nullptr; - + memdelete(navigation_2d_server); navigation_2d_server = nullptr; }