diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-26 10:12:19 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-26 10:12:19 +0200 |
commit | 710d2e7edf54c477a15c7bc3fb91ead394b51fd9 (patch) | |
tree | f25e8a5e405ef98417a19f4943ca185da768ec4e /modules/navigation/nav_agent.cpp | |
parent | a93c671b7d59d9d9be76558a8cc53bd87a0f42d1 (diff) | |
parent | 4ae5dcca4563743d6c09c67e262c516020174fc4 (diff) | |
download | redot-engine-710d2e7edf54c477a15c7bc3fb91ead394b51fd9.tar.gz |
Merge pull request #78665 from smix8/fix_navobjects_map_4.x
Fix NavObjects map assignments
Diffstat (limited to 'modules/navigation/nav_agent.cpp')
-rw-r--r-- | modules/navigation/nav_agent.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/navigation/nav_agent.cpp b/modules/navigation/nav_agent.cpp index 19b73dc633..010bd2d7c0 100644 --- a/modules/navigation/nav_agent.cpp +++ b/modules/navigation/nav_agent.cpp @@ -90,8 +90,23 @@ void NavAgent::_update_rvo_agent_properties() { } void NavAgent::set_map(NavMap *p_map) { + if (map == p_map) { + return; + } + + if (map) { + map->remove_agent(this); + } + map = p_map; agent_dirty = true; + + if (map) { + map->add_agent(this); + if (avoidance_enabled) { + map->set_agent_as_controlled(this); + } + } } bool NavAgent::is_map_changed() { |