summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorsmix8 <52464204+smix8@users.noreply.github.com>2023-04-07 17:44:40 +0200
committerYuri Sizov <yuris@humnom.net>2023-04-07 17:44:40 +0200
commit675547845ed26c2b74f029b64f38d585c3934f1f (patch)
tree79448281b023fa397b5a5fb9fd7efd2b5a6a3a52 /scene/3d
parent210879d28451be465af9c19b008f6f5258c8fb7d (diff)
Fix NavigationObstacles not being added to avoidance simulation
Fixes NavigationObstacles not being added to avoidance simulation. (cherry picked from commit aadf33efd8a79a038b842dc91c63784302efd753)
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp7
-rw-r--r--scene/3d/navigation_obstacle_3d.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp
index 85b3c164cc..14d93fb0e0 100644
--- a/scene/3d/navigation_obstacle_3d.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -203,13 +203,20 @@ void NavigationObstacle3D::set_agent_parent(Node *p_agent_parent) {
} else {
NavigationServer3D::get_singleton()->agent_set_map(get_rid(), parent_node3d->get_world_3d()->get_navigation_map());
}
+ // Need to register Callback as obstacle requires a valid Callback to be added to avoidance simulation.
+ NavigationServer3D::get_singleton()->agent_set_callback(get_rid(), callable_mp(this, &NavigationObstacle3D::_avoidance_done));
reevaluate_agent_radius();
} else {
parent_node3d = nullptr;
NavigationServer3D::get_singleton()->agent_set_map(get_rid(), RID());
+ NavigationServer3D::get_singleton()->agent_set_callback(agent, Callable());
}
}
+void NavigationObstacle3D::_avoidance_done(Vector3 p_new_velocity) {
+ // Dummy function as obstacle requires a valid Callback to be added to avoidance simulation.
+}
+
void NavigationObstacle3D::set_navigation_map(RID p_navigation_map) {
if (map_override == p_navigation_map) {
return;
diff --git a/scene/3d/navigation_obstacle_3d.h b/scene/3d/navigation_obstacle_3d.h
index 416b32c026..c5a9d737f6 100644
--- a/scene/3d/navigation_obstacle_3d.h
+++ b/scene/3d/navigation_obstacle_3d.h
@@ -74,6 +74,8 @@ public:
PackedStringArray get_configuration_warnings() const override;
+ void _avoidance_done(Vector3 p_new_velocity); // Dummy
+
private:
void initialize_agent();
void reevaluate_agent_radius();