@aron_granberg Hopefully this will explain what is going on as per your questions:
“Well… I have been recommending another solution in the last few posts.”
-It isn’t that I’ve ignored them (I think these quotes summarize them):
“I think you should consider using multiple different graphs instead”
“Use multiple Seeker scripts with each one corresponding to a agent type / size (so Small Seeker, Medium Seeker, Large Seeker).? RE: Yes, something very similar to that.”
-In the grand scheme of things, the two problems I was having was cutting large sections of the navmesh and then updating large sections of the navmesh node tag data. Using your multiple graph suggestion (or my modified single graph) does eliminate pretty much all the issues with the cutting of the mesh (only the agents would need to cut anything), so that is good.
-However, neither approach addresses the problem of nodes losing their tag data when re-cut (which again requires the updating of large areas of the navmesh). That key fact is a large oversight on my part, really should have remembered that earlier.
-That being the case, my method of changing how the initial cutting is done and using only 1 graph just simplifies the setup and operation.
-So my newest thought was to just ‘re-load’ the pre-created navmesh after agent cutting / pathfinding was done. It would re-establish all the node and tag data (and seemed to be quite a fast operation), so it is possibly the best way to accomplish this from a performance standpoint. Unfortunately I can’t seem to do it without errors (more on that at the end of this post).
“I thought you wouldn’t cut the navmesh more than at the beginning of the game now? Why do you need to cut it again?”
-I realize that my setup probably is very strange to someone that isn’t looking directly at it, so, I’ve tried to prepare a image that will give you a much better idea about what is actually happening:
So here, I have created ‘areas’ that define ideal places for agents of different size to operate (basically by defining 2 ‘outer areas’ that use cutting and then 1 ‘middle area’ that functions as a ‘buffer’ to keep cutting scripts from merging areas that share an edge. All areas then have their tag data changed to reflect the type of area they are.
In this example, a blockage has occurred (agents cut an area around them to invalidate the area under them and around them), and because of this all the agents must take path around it instead of just using ‘large area’ to go straight to it.
So each unit follows its own logic:
Large Agent: allowed to use Medium areas if absolutely necessary (determined by script) to reach the destination (‘medium areas’ carry a high penalty, and ‘small area’ is not allowed at all).
Medium Agent: also uses ‘medium area’ (carries no penalty at all, nor does ‘large area’).
Small Agent: uses ‘small area’ (no penalties for any type of area node) but using ‘small area’ results in the shortest path in this case.
This could of course be changed to allow more risky / more conservative pathing, as well as even forcing all units to use larger areas (giving a slight penalty to other types that would still be okay to use) for more safety.
However, once the blockage clears, the nodes will have lost their data (having gone from: original ‘area tag’ -> ‘invalid tag’ -> nothing. This still requires updating of node data (1 of the 2 original problems). Hence my attempt to re-load the original data.
“Do you happen to have a longer stacktrace for that?”
-Here are two images of the errors, “IndexOutOfRangeException” occurs 1 time per occurrence, “GraphDoesn’tExist” happens more than 1 time (and the amount is variable).
“The only case where all tags would definitely be defined where if the tags were set before any cutting was done.”
-Well, I do have a ‘pre-created’ navmesh with tag info before the agents try to do any cutting. So it would in theory be possible to know which nodes you are about to cut over, save their tag data, then after cutting / pathfinding when the navmeshcut script is turned off and the navmesh ‘goes back to its original state’, the data for those nodes could then be re-applied?