diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-04-23 10:14:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-23 10:14:04 +0200 |
commit | a3fbc0b4e5a690c0a232d7780fef1224257be6cb (patch) | |
tree | 600d930adb3a27427bdef2a18d7f85a209710fae | |
parent | bd7a92ec23a1d33795c5310652f54c529516cd29 (diff) | |
parent | 15bf337474c5584303d248350dfcc882d9ac0b83 (diff) |
Merge pull request #48028 from smix8/issue_47337_broken_navagent3d_callback
-rw-r--r-- | scene/3d/navigation_agent_3d.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 7346f243ba..4f5e56e227 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -34,6 +34,8 @@ #include "servers/navigation_server_3d.h" void NavigationAgent3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_rid"), &NavigationAgent3D::get_rid); + ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent3D::set_target_desired_distance); ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent3D::get_target_desired_distance); @@ -95,8 +97,11 @@ void NavigationAgent3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { agent_parent = Object::cast_to<Node3D>(get_parent()); - - NavigationServer3D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); + if (agent_parent != nullptr) { + // place agent on navigation map first or else the RVO agent callback creation fails silently later + NavigationServer3D::get_singleton()->agent_set_map(get_rid(), agent_parent->get_world_3d()->get_navigation_map()); + NavigationServer3D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); + } set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { |