So, I have a generated terrain split into chunks and I’ve been using the procedural graph mover to generate a recast graph at runtime as the chunks are loaded, which works for right now thanks to the performance improvements. The problem is, the graph will generate gaps when moving due to the chunks on the edge of loaded area not existing at the time the graph is generated, meaning as soon as you walk beyond the 3x3 initially loaded chunks, the new chunk is loaded in and then the graph is moved, but the gap at the edge is never filled in, so NPCs can’t cross an invisible line:
is there anyway to remedy this without some ridiculous hack like adding temporary geometry?
My second question is, at some point I’ll need it to perform even faster by generating the navmeshes when the map is created and then saving and loading them to disk instead, like I do with the rest of the terrain (map generation happens independently outside of regular gameplay) is it possible to do this without having to actually instantiate every object off screen just to generate the graph, i.e. by passing mesh data without it existing in the scene?
You could see how these two problems combined would be a major pain, if I both can’t get rid of the lines and I need to instantiate every chunk off screen just to generate it’s graph, then I’ll have to load each chunk and all chunks surrounding it off screen during the map generation process which will make an already not-so-quick operation dramatically slower (unless I hack it with border pieces).
Whatever the case, thanks in advance, this project is the GOAT Unity asset.
Can you maybe do a scan after the map has loaded the new area? Like, right after it’s in and loaded use AstarPath.Scan()?
Are you trying to load the procedural graph mover’s graph? If that’s the case, I’d say that there’s not many situations I can see where that’s the intended use for procedural graph mover. If you are using both, let me know why- I’m probably just missing some important context Maybe you’re referring to a different second graph here?
Does that re-scan the entire existing area? Hitting the button in GUI does solve the problem, however it also takes a couple seconds which sort of spoils the whole thing.
Haha no, not trying to do that. I’m talking about a future state. Currently, I have the procedural graph mover crossing the landscape with the player during game play, generating the navmesh immediately after a chunk is loaded, instead, to improve runtime performance, I plan to generate navmeshes for each chunk during the map generation process.
The map generation is a fixed size, done in a separate menu before gameplay starts, and serializes each chunk’s data to the disk to be loaded as needed at runtime. This chunk data in the future state will include the serialized piece of navmesh for that chunk which will be added to the graph once the chunk is loaded, removing the need for the procedural graph mover entirely.
Hope I communicated that a little better, let me know if you want more details, and thanks for the reply.
Well, because I needed to get better performance anyways, I went ahead and added the graph scanning to the terrain generation. Here I have graphs which were generated earlier, serialized and deserialzed at runtime - I also threw in that fake geometry I talked about to get rid of the edges.
Somewhat surprisingly; serializing and deserializing graphs doesn’t appear to be faster than just generating them in real time with the graph mover like I’d assumed (anecdotally, I haven’t done any timing), and now produce a separate graph for each chunk which the agents can’t move between anyways.
Is it possible to just serialize the navmesh instead of the entire graph and add the nodes to an existing graph (as well as delete those nodes stored in a list at the time a chunk is unloaded)? Or serialize individual tiles used by the graph mover and just pass them to it so no scanning has to happen? I very desperately need this to perform better and will go to great lengths to make it happen.
I don’t believe there’s any built-in way of doing this verbatim, however you may want to look into DeserializeGraphsAdditive. It creates a new graph, though. Off the top of my head I’m pretty sure you’d have to recreate connections along the edges to get them to link together.
Ahh fair. So my logic here is just, manually doing what you want to do- adding nodes and then adding connections. But I’m looking at it and neither CreateNodes() and CreateNodeConnections() are public. (Of course that doesn’t mean it’s suddenly impossible just a barrier you’d have to overcome). There is the ability to write your own graph generator though, if you want to try that route for something more fit for your project. Not that this suddenly “fixes your problem” but it’s just something worth keeping in mind–
That said I’m gonna tag Aron here since this gets pretty deep into the infrastructure of the asset and I’d like to hear what his recommendation would be here, too.