Skip to content

Commit

Permalink
Fix broken NavigationAgent3D collision avoidance callback
Browse files Browse the repository at this point in the history
Fix broken NavigationAgent3D collision avoidance callback
  • Loading branch information
smix8 committed Apr 19, 2021
1 parent f817e7f commit 15bf337
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scene/3d/navigation_agent_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 15bf337

Please sign in to comment.