A* Pathfinding Project

Updating a layered grid graph bounds without removing previous nodes


Hey, I’ve recently run into a bug which is specific to my game’s graph baking which I’m curious to see if you can assist with

So at load time, I load each of my room prefabs one after the other and bake the layered grid graph for that room’s bounds

      for (int i = 0; i < roomPrefab.additionalBounds.Count; i++) {

However, I’ve run into an issue where updating a graph with a room that has an area above another room deletes all of the nodes for the other room. This is because I disable each room after it loads

Before baking the upstairs room:

After baking the upstairs room:

So my question is, is there a way to update a graph based on a bounds area, but only add new nodes without deleting any that already exist?



A layered grid graph has to recalculate all nodes within the same x, z cell at the same time. So all nodes that are stacked on top of each other.
Is there a reason you cannot have all rooms active at the same time while you are generating the graph?