Pathfinding in an infinite procedural world with detailed interiors/multiple stories

I’m looking at joining pre baked recast graphs at runtime. I essentially have terrain tile pieces I load/unload from the scene at runtime and I need to figure out a way to be able to path find on my procedural world.

I tried the procedural example with the grid graph but there’s a few problems:

  1. For some reason the pathfinding messes up whenever I try to run away from my AI (it doesn’t understand how to chase me properly). Without a visualization for this out of the box, it’s hard to tell what’s going on with it exactly, but the problem isn’t present with a baked recast/gridgraph, just the procedural graph mover.

  2. I require detailed indoor areas in my massive outdoor levels. a Layered GridGraph version of the procedural mover script would be wonderful (if I could figure out the problem listed above).

So here’s my issue: The graph needs to be able to handle infinite worlds. I’m looking to build procedural outdoor levels using pre-made piece variations but since what piece connects to what other piece is randomly determined, I cannot just pre bake one big graph. I can pre bake multiple small graphs since each chunk is in a different Unity scene but I’m stumped as to how to merge multiple small graphs into one big one correctly.

So here are my questions:

  1. Any chance we’ll get a Layered Grid Mover script for us Pro users? The issue I had sounds like it could be fixable and that would probably be easier to figure out than creating my own graph frankestein monster as below.

  2. If there’s no chance for a layered grid graph mover script, how can I go about joining recast graphs together at runtime, if they are being imported from their own Unity scenes? IE: I have Scenes 1, 2 and 3 created and each has their own recast graph pre-baked. I load scene 3 into scene 1 at runtime, how would I go about joining the edges of these two graphs so that the AI can chase me from one graph and into the other in the case that AI chases me to the edge of its graph and into the next?

  3. If I have to go with Recast graphs, is there a way for me to add new geometry to them and have my units path find on them? IE: I craft a building with two floors in an empty patch of terrain, and graph updates with the building’s interior. I know you can subtract walkability from a recast graph, but can you add new walkable areas to it somehow at runtime? Like a 2 story building with walkable upstairs areas? Can I maybe just do a scan on just that tile in a background thread or something?

Thanks in advance!


Hm, maybe you are trying to order it to a point outside the calculated graph, then it wouldn’t know the best path to get there.

  1. Layered Grid Graph version of the procedural graph mover is not something I am working on right now (it is slightly more complicated to do). Sorry.

  2. Well, that IS possible, it is just very undocumented.
    Basically you would need to save the recast tiles as meshes and then load it in like described in that post. Can be tricky to get it to work. The reason it is very undocumented at the moment is that the API wasn’t at start built for this purpose, it was built to handle navmesh cuts, it just also happens to be possible to do these kinds of things with it as well.

  3. No really possible at the moment (well, technically, but not in a stable way at the moment). Adding geometry is much harder than removing it.

You could opt for recalculating tiles of the recast graph during runtime, however that could end up being really slow (even though it is offloaded to a separate thread during calculation it still takes some time). See documentation about updating graphs.

Sorry for a lot of disappointing answers.


The link mentioned in your post above doesn’t work. Can you post an updated link?



I am not sure which exact thread the link referred to, but here is a list of posts that might be relevant: