Fix NavigationObstacle nodes not registering to default navigation map

Fix NavigationObstacle nodes not registering to default navigation map.
This commit is contained in:
smix8 2022-08-13 19:46:12 +02:00
parent 1806e414b8
commit 47b39ce4c2
2 changed files with 12 additions and 2 deletions

View File

@ -139,7 +139,12 @@ void NavigationObstacle2D::set_navigation(Navigation2D *p_nav) {
}
navigation = p_nav;
Navigation2DServer::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
if (navigation != nullptr) {
Navigation2DServer::get_singleton()->agent_set_map(agent, navigation->get_rid());
} else if (parent_node2d && parent_node2d->is_inside_tree()) {
Navigation2DServer::get_singleton()->agent_set_map(agent, parent_node2d->get_world_2d()->get_navigation_map());
}
}
void NavigationObstacle2D::set_navigation_node(Node *p_nav) {

View File

@ -145,7 +145,12 @@ void NavigationObstacle::set_navigation(Navigation *p_nav) {
}
navigation = p_nav;
NavigationServer::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
if (navigation != nullptr) {
NavigationServer::get_singleton()->agent_set_map(agent, navigation->get_rid());
} else if (parent_spatial && parent_spatial->is_inside_tree()) {
NavigationServer::get_singleton()->agent_set_map(agent, parent_spatial->get_world()->get_navigation_map());
}
}
void NavigationObstacle::set_navigation_node(Node *p_nav) {