From aabd293f3b736aaae4e7570bca3ca131fa20dec2 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 16 Apr 2023 18:20:15 +0200 Subject: [PATCH] Allocate the selected navigation srevers. --- main/main.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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; }