Closed Nukiloco closed 2 years ago
For the second issue, avoidance_enabled
on the NavigationAgent2D
should be true in order to get the signal.
Please create separate issues. You can refer to an another issue if they are linked.
Second issue as others mentioned you need to enabled avoidance on the node, connect the signal and use set_velocity().
For the first performance issue that is not a NavigationAgent issue or bug but a project specific navigation layout issue that tanks your performance. When a path is possible AStar will do an early exit as soon as a path is found. Since your path is impossible while in the box AStar searches all available and connected navpolygons everytime which results in the noticeable lag difference between when a path is possible or impossible.
So why the lag inside the box? Each baked navigationpolygon has at least 3-4 polygon edges and creates a navigationregion on the navigationmap. Your TileMap has 15264 cells and 14264 of them use the baked navigationpolygon. The lag at the startup is because the NavigationServer needs to dig through all those regions to connect the edges. Also that is around 50000+ polygon edges that the navigation path query has to dig through everytime the navigationagent requests a path while inside that impossible box which is an unreasonable amount for navigation performance.
At that project scale with such small TileMap cell sizes you really should no longer use the tile baked navigationpolygons and work with a NavigationPolygonInstance. 3D will have the same performance issues with so many, small cells when every cells uses its own NavigationMeshInstance.
First yea avoidance was the reason why it wasn't sending safe_velocity
.
Second, I was using a TileMap in my game as a way for players to use tiles to build obstacles against enemies. I didn't know that TileMaps didn't optimize the points at all, though I guess it makes more sense now why it would be lagging. Thanks for the confirmation that this wasn't a bug.
@smix8 Is there anywhere this could be documented (specifically in the class reference)?
Godot version
v3.5.1.stable.official [6fed1ffa3]
System information
Windows 10, Nvidia GTX 750 TI, Nvidia GTX 1050 TI
Issue description
This originally meant to be about one issue but I think I ended up finding another issue as well, it just happens that both issues can be reproduced in this project.
It seems like with huge tile maps, the navigation agent will tank your FPS when your in an area where the agent can't reach you. I don't think lag issues like this will happen when you are using 3D nodes instead. I expect the FPS to stay the same even when using large tile maps like this.
Second issue,
velocity_computed
used to work but when updating my Godot project, it has been broken as far as I know of and never sends any velocity_computed signals at all. I should probably test when this was broken. I expect this to completely work and send a velocity through thevelocity_computed
signal.Steps to reproduce
Download the minimal reproduction project below, extract the project, open up the project and press F5.
First issue, when you run the minimal reproduction project, the game will lag completely. By moving with the arrow keys, from the small area, into the huge area, the game will stop lagging.
Second issue, I remember when updating my Godot project that
velocity_computed
used to work before with this code, but it no longer does now. I need to do some more testing to see when this was broken.Minimal reproduction project
GodotNavigationAgentLagIssue.zip