Layered Grid Graph / Something Else?


I’m not sure if I’m being completely dense here or not, but I’m not understanding how I can populate all the parts of a LayeredGridGraph at runtime. I’m looking to implement some basic navigation which follows similar rules to the way Dwarf Fortress does. A quick summary is 1x1x1 block in Unity is going to be one of the following:

  • Air (flyable)
  • Ground (walkable)
  • Wall
  • Stairs (walkable) - a path directly +1 or -1 Y level.
  • Ramp (walkable) - a path +1 or -1 Y level, but also translates X/Z depending on the direction of travel
  • Fluid

After battling with the LayeredGridGraph for a while, I’m starting to think I’m rather obtuse here, because I can’t see how I can populate this information from nothing once my world is generated in code. Can anyone point me in the right direction?

Updated my original post and removing this follow-up :slight_smile:


Currently there is no support for populating this data from code. However what you can do is to subclass the LayerGridGraph class and override the RecalculateCell method. There you will be able to create the nodes however you like. This will then work out of the box with graph updates as well. To generate the connections in a custom way you may have to override the CalculateConnections method as well.