From 9640179f9308a4ca69905bfbe128812f6f0e2a3a Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Mon, 23 Oct 2023 04:27:49 +0200 Subject: [PATCH] Fix missing NavigationAgent property updates in constructor Fixes missing NavigationAgent property updates in constructor. --- scene/2d/navigation_agent_2d.cpp | 12 +++++++----- scene/3d/navigation_agent_3d.cpp | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index 1b3b0bcef0b..a45d9f2fa86 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -294,6 +294,13 @@ NavigationAgent2D::NavigationAgent2D() { NavigationServer2D::get_singleton()->agent_set_time_horizon_obstacles(agent, time_horizon_obstacles); NavigationServer2D::get_singleton()->agent_set_radius(agent, radius); NavigationServer2D::get_singleton()->agent_set_max_speed(agent, max_speed); + NavigationServer2D::get_singleton()->agent_set_avoidance_layers(agent, avoidance_layers); + NavigationServer2D::get_singleton()->agent_set_avoidance_mask(agent, avoidance_mask); + NavigationServer2D::get_singleton()->agent_set_avoidance_priority(agent, avoidance_priority); + NavigationServer2D::get_singleton()->agent_set_avoidance_enabled(agent, avoidance_enabled); + if (avoidance_enabled) { + NavigationServer2D::get_singleton()->agent_set_avoidance_callback(agent, callable_mp(this, &NavigationAgent2D::_avoidance_done)); + } // Preallocate query and result objects to improve performance. navigation_query = Ref(); @@ -302,11 +309,6 @@ NavigationAgent2D::NavigationAgent2D() { navigation_result = Ref(); navigation_result.instantiate(); - set_avoidance_layers(avoidance_layers); - set_avoidance_mask(avoidance_mask); - set_avoidance_priority(avoidance_priority); - set_avoidance_enabled(avoidance_enabled); - #ifdef DEBUG_ENABLED NavigationServer2D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent2D::_navigation_debug_changed)); #endif // DEBUG_ENABLED diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 87b8087e44b..55f74983e92 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -329,6 +329,14 @@ NavigationAgent3D::NavigationAgent3D() { NavigationServer3D::get_singleton()->agent_set_radius(agent, radius); NavigationServer3D::get_singleton()->agent_set_height(agent, height); NavigationServer3D::get_singleton()->agent_set_max_speed(agent, max_speed); + NavigationServer3D::get_singleton()->agent_set_avoidance_layers(agent, avoidance_layers); + NavigationServer3D::get_singleton()->agent_set_avoidance_mask(agent, avoidance_mask); + NavigationServer3D::get_singleton()->agent_set_avoidance_priority(agent, avoidance_priority); + NavigationServer3D::get_singleton()->agent_set_use_3d_avoidance(agent, use_3d_avoidance); + NavigationServer3D::get_singleton()->agent_set_avoidance_enabled(agent, avoidance_enabled); + if (avoidance_enabled) { + NavigationServer3D::get_singleton()->agent_set_avoidance_callback(agent, callable_mp(this, &NavigationAgent3D::_avoidance_done)); + } // Preallocate query and result objects to improve performance. navigation_query = Ref(); @@ -337,12 +345,6 @@ NavigationAgent3D::NavigationAgent3D() { navigation_result = Ref(); navigation_result.instantiate(); - set_avoidance_layers(avoidance_layers); - set_avoidance_mask(avoidance_mask); - set_avoidance_priority(avoidance_priority); - set_use_3d_avoidance(use_3d_avoidance); - set_avoidance_enabled(avoidance_enabled); - #ifdef DEBUG_ENABLED NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent3D::_navigation_debug_changed)); #endif // DEBUG_ENABLED