When this scene is loaded, it loads any saved objects first, then it sets the NavigationRegion Polygon to NavigationPolygon.new(), then it bakes it. Can someone please tell me why some NPC’s path’s go around the objects and some try and go through them?
my guess is this has more to do with the configuration of the npc that isn’t acting correctly. if it’s working for one of them then I would venture that your implementation is correct however I would imagine there is some small difference between the npcs settings causing the variance. maybe try removing the one that doesnt work and use a copy of the one that does instead and if you find it works correctly then that pretty much confirms it.
This layout and path looks like you have both the baked NavigationRegion2D navigation mesh and the TileMap build-in navigation mesh regions active at the same time. Disable the TileMap navigation layer if you use a NavigationRegion2D to bake the TileMap, else you have 2+ overlapping navigation mesh surfaces creating conflicts.
Navigation polygons are usually baked ahead of time, not when the scene loads.
My guess would be that one agent determines its path before the navigation polygon appears (or with the old one?) and the second does pathfinding on the “updated” one.
I see. I thought if I used, group with children, and made the Objects children of the tilemap, it would make the navigation always the size of the wooden tiles with holes where the objects are. I was wondering why it looked like there were 2 layers. I will try this thank you.
The peoblem is, the player can place more objects down and the NPCs need to to navigate around them. So the signal, children ordered changed, is connected to the function bake navigation polygon. It updates throughout gameplay
I believe so. I am not using obstacles because baking the polygon already omits the Static Bodies in the Navigation. Also, i think not using Obstacles is better for performance.
I haven’t had time to work on it yet. But i believe my mistake was baking the polygon with the Wooden Floor Tiles included. I thought this would automatically create a nav polygon the prrfect size of the floor map. But this caused the NavAgent on NPCs to consider all areas with those tiles as free to navigate. I think the solution will be to manually create a nav polygon for each room size upgrade and not assign navigation to the wooden tiles. If this makes sense.
So, I created a Nav Polygon for each room size upgrade. However, I don’t understand how to add that to the Nav Region or Nav Map/Server. I have been experimenting but could not figure it out. Can someone look over this code and tell me how to make it work? When I do this, the room addition doesn’t have the polygon and there is no Navigation in that part.
You dont see debug visuals for changes that you do with the NavigationServer API. The debug visuals are done by the nodes, you need to set the updated navigation mesh on a NavigationRegion2D node to get debug rendered.
Tank you for your help, it works pretty good now. The player can upgrade space and when he enters the building the navigation is extended. However, it doesn’t stay. If he leaves and exits, the navigation is there.
Does the Navigation Server save the Navigation Map on the different Scenes?
It also does not care what happens in the SceneTree, e.g. a SceneTree scene change does not exist for the server. If you use nodes they will manage their own server objects on a scene switch but if you use the server directly you need to manage everything manually.