I’ve been recently looking into voxel solutions for Unity and the one thing keeping me from going into one of them is that I’m concerned that doing pathfinding on it will be a nightmare.
Off the top of my head I’m thinking using recast on a dynamically changing voxel world will be a no-go, since the player breaking any voxels or “digging” would require an a graph update and recast is very slow to do so.
Grids may be a better way, but I know that even scanning a grid can make the gameplay “lag” or “stutter” a bit if the graph you’re scanning is too big.
So I was really wondering if this is something you have thought about, with the growing popularity of voxel terrains, and if you had any suggestions as to the best way to implement pathfinding using your system on them. Look forward to hearing what you think.
The best solution currently is to use a multi layer grid graph (or just grid graph, but that is restricted to one layer). Recalculating a small area is not that slow, recalculating everything would be quite slow though, but luckily you can update just a small area of it.
It is much faster when updating only a small part.
However due to the need to flood fill the graph (precomputing which connected components there are in the graph). Updating a small part of a large graph can have a large cost. You can set myGUO.requiresFloodFill to false if you know it will not divide the graph into two separate connected components.
For infinite terrain worlds, what I think is best is that keep a grid centered around the player, then when the player gets too far away to one side of it, move the grid and rescan it completely so that the player is in the center again.
Sounds good, I may give it a shot if I decide to try out voxels in the near future. Does the graph total size matter if you’re using a GUO to update a small part of it? For example, updating a 1x1 square on the graph, is it the same performance on a grid that’s 1024x1024 as it would be one one that’s 100x100?
I was also thinking about infinite terrain worlds. I suppose the right solution for those would be to have multiple grids.