My setup is as follows:
- 2048*2048 map
- Using Recast
- About 20k trees some of which are added or deleted (chopped down) during run time - using Navmesh cut to add/remove them as obstacles
- Houses added / removed during runtime - using UpdateGraphs
So far it all works fine and fast.
The last piece of the puzzle are roads which I have marked in my splat map - and which are also dynamic - ie. places that are more trafficked will become “roads”, places that are less will slowly go away.
The way I have this solved using Unity’s navmesh was to create “road marker” gameobjects with a different navmesh layer that Unity would then catch and I could assign a different cost for pathfinding.
My first attempt at this with A* was to assign penalties through GraphUpdateObject - which leads to 2 problems:
This results in a very approximative shape of the road - ie. it catches the navmesh triangles that intersect the road - which is to be expected I assume. So this raises question 1 - is there any way I can influence the navmesh shape so that it generates finer triangles along the path? Maybe adding small navmeshcut objects along the way?
The navmesh is often updated - either by adding/removing navmeshcut components (cut a tree) or by adding/removing houses. The problem is that the update operations result in new nodes that of course, do not inherit the penalty/tags previously set. These realculations happen relatively often so I’m not sure reapplying the updates every time is a great idea.
I’ve also tried replicating my Unity navmesh approach for a bit - ie. generating the road markers (several hundred gameobjects) but A* seemed to hang on the update (ie. had several hundred objects to rasterize). I could try merging all those objects into one, or generate a shape but that would be a time consuming undertaking that I’m not looking forward to unless I think it’s the way to go.
Is there a way to supply A* a texture or a volume that it would check against and assign penalties to new nodes as they’re generated?
I very shortly looked into grid graphs but that looks like an inferior approach to recast for my needs.