-
-
Notifications
You must be signed in to change notification settings - Fork 20.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing and re-adding Navigation and NavigationAgent to SceneTree inconsistent behavior #62103
Comments
CC @smix8 This might be fixed in current |
Tested with the |
The NavigationAgent (re)parent fixes from Godot 4.0 were only recently added to Godot 3.5 with #61996 that should be part of 3.5 RC4 when it is released. Godot 3.5 is a little quirky cause it has still the old EDIT |
Note that the test project for 3.5 had the agent placed at the wrong position for automatic (re)join fo the navigation map. It must be below the navigation node or else it will register to the default world navigation map which causes the agent to break cause this map is empty and has no navigation mesh. If it is desired to have the agent at another position using |
Fixed by #62117. |
@akien-mga @smix8 I've tested the latest build. I have found a combination of methods that work great, but the API is now confusing. Please correct me if I misunderstood something, because I would really like to document this properly. With the new navigation system, engine users have two choices: LegacyUse the The When calling However, if calling I understand that the Godot 4Place
|
When NavigationAgent enters the tree again calling Godot 4.0 and 3.5 navigation work the same now but 3.5 has some old stuff kept around for compatibility with existing scenes. What is shared with both version is that every world resource creates a default navigation map and every navigation related node like regions and agents join this map if not told otherwise. That said Godot 3.5 has still the old |
@smix8 Amazing, thank you. I'll poke around the docs on Monday and try to update them with this information to make it clearer for devs. Final question, some useful methods require a map RID to work, e.g. Is there another way to get the default/world map RID? |
@TheOrioli The default 2D navigation map can be optained from any |
Godot version
3.5.rc3
System information
Windows 10
Issue description
When removing and re-adding a Navigation and a NavigationAgent node to the SceneTree they appear to randomly stop working. The randomness comes from the inconsistence between the different setups of the NavigationAgent.
Problem cases
avoidance_enabled
is falseWhen
_enter_tree
is called on the NavigationAgent, callingset_navigation
again will be enough to let calls to methods such asget_next_location
oris_target_reached
to work.avoidance_enabled
is trueWhen the NavigationAgent uses avoidance, it is not enough to call
set_navigation
when entering tree again. The Navigation node itself must be readied again by callingrequest_ready
before it is re-added to the tree. If bothrequest_ready
on the Navigation node andset_navigation
on NavigationAgent are called than the agent will work as expected.Workaround
Add a call to
request_ready
on Navigation in_exit_tree
, callset_navigation
on NavigationAgent's in_enter_tree
after the first time the navigation is setup by keeping references to the Navigation node. This provides a consistent behavior across all agents.Expected behavior
Manipulating Navigation related nodes in the SceneTree should not require manually keeping track of the state.
At the very least the
request_ready
call on the Navigation should not be necessary, I don't think any other built-in node requires "manual resetting" of it's state when exiting/entering the tree. If theset_navigation
is required it should be documented in the NavigationAgent class.Everything works as expected in Godot 4 Alpha 10. This issue is not present. Calling
request_ready
is unnecessary and theset_navigation
call doesn't exist.Steps to reproduce
Run the sample project, press the Remove/Add button to move the Navigation and NavigationAgent nodes from the scene tree, use the various checkbox to toggle what methods get called and if the NavigationAgent has avoidance enabled.
Minimal reproduction project
navagent_reparent_repro.zip
navagent_reparent_repro_godot4.zip
The text was updated successfully, but these errors were encountered: