Procedurally Generated Dungeons - Can't load graph cache properly

Hello,

I have been swapping over my game ZIX from navmesh stuff (specifically the runtime based, navmeshsurfaces etc…) over to this system, because I was having a bunch of problems and also was intrigued by the fact that this has steering behaviours.

I’ve got decently far along, including getting the system to play well with what I already have (I move all my entities using physics).

My problem is now that I want to cache this data, and then load it for when I generate the entire map, and then be able to link up the doors together using Links.

I am however stuck here:

I was able to finally load that graph additively using the cache, but I can’t move the nodes so that they are scaled locally… I think part of the problem is that when the RecastGraph generates, it assumes the entire scene is the origin, whereas it realistically should only be applying to the object, basically generating a local graph for this prefab… Anyways, my last part to solve is really to be able to move those nodes by a certain amount to get them to line up with the levels I’ve spawned at runtime, and I have no idea how to go about doing that.

Also just in general, I don’t know what the intended flow for doing stuff like this is…

This is how I did it using Unitys NavMeshSurface:

  1. Add NavMeshSurface to the GameObject
  2. Press build, which generates it relative to the game object
  3. Prefab the chunk with this new data
  4. Instantiate the chunk at the right place, aligning doors etc…
  5. Hook up door navmeshlinks

That was working quite fine, I had no issues with it, but Unity is way too restrictive with their API and there’s stuff that’s really not easy to do with that kind of system.

I would love if this is just as simple using this system… not sure if I’m misunderstanding how to do stuff… Some assistance would be INSANELY appreciated… it’s the last blocker before we can just move on to continuing building content with this.

Thanks a lot for reading, looking forward to any ideas.

Hi

Moving the graph after loading it currently has to be done using code. You can use (AstarPath.active.graphs[index] as RecastGraph).RelocateNodes.

See NavmeshBase - A* Pathfinding Project

Ok well we got quite far relocating and adding the cached graph additively. The main issue that’s left is performing the right matrix to get it to the right point which I’m having trouble with at the moment but is doable.

One thing that I’m wondering is if it’s possible to save that graph local to the game object instead of the scene, how that would be done or if it’s possible for you to extend the system to be capable of doing local scans and saves, or creating a “LocalRecastGraph”.

I’d be happy to extend it myself and send you the script to upgrade the system as a whole, guidance would be appreciated however on how to do this.

Hi

Did you check the overload which takes a GraphTransform and not a matrix? Check the code example for it. It allows you to specify the center of the graph instead, which should be much easier.

I got it working with the matrices, I should’ve checked this earlier, I’ll see if that makes it any easier.

1 Like