2d Grids- Would Pro be worth the access to Layered Grids in the following?

I am using tilemaps and I am utlizing A* Pathfinding for the navigation of the characters on the map. I will have mutliple tile maps for ground level, basement 1, basement 2, basement 3… etc. They are stacked on top of each other seperated by the z axis. Now I have a layer for my obstructions for the ground level. In order for the Agrids to detect the different obstructions on basement 1,2,3,4… I need to setup a new layer for each level. this would limit my levels I could have. I do need to have the A grids in place and cannot move them and I cannot move the obstruction tilemap with the obstruction layer. How I have it now works. But if A* Layered Grids could use one obstruction layer and be able to detect that the 2d tilemap collider is on a different z axis that would help my project. I am okay with the limited levels but would be cool not to be bound by that.



My understanding, albeit a vague one, of Layered Grid Graphs and 2D games is that they work but it’s definitely “made for 3D”. I do know that they work from a previous question I was helping on, and if you add an obstacle to one “layer” it does apply it to them all, which made it difficult (if not impossible) to use it for layered floors with differing obstacles.

What complications are you running into with making bespoke graphs for each “layer” with a normal Grid Graph?

It comes with it limits due to the fact I can only have 32 layers in total and each grid graph needs it’s own tilemap with an assigned layer.

Also I am thinking that I am getting stutters to my game when i use because of the amount of graphs.

AstarPath.active.AddWorkItem(() => {
currentObstructionTileMap.gameObject.GetComponent().DoUpdateGraphs();
});

Thank you for your reply though :slight_smile:

Hi, sorry for the late reply!

If you only need one layer active at a time, what about having your relevant obstacles disabled and only enabled when on that level? Then rescan when changed, rather than trying to hold all the levels in memory? As an aside, you can also save graph data and apply it during runtime but I think this is all dependent on what your individual project needs. Feel free to break it down some more for me or let me know what I’m misunderstanding in this and I’ll help explore some options with you? :smiley:

And for this, when are you calling this? How often/under what needs?

I am using all the grids because I have multiple objects using them at different times. So disabling or using just one and moving it around when needed wouldn’t be effective.

I am only calling that when I make or destroy and obstruction on the obstruction layer which is maybe once every 1-3 seconds at most but typically once every 20-60 seconds realistically. Is it because I am using the free version and I can only use on thread for calculations?

Ahh so these levels are all being used at any given time. I see.

Well, I will say, that Recast Graphs are a Pro feature but they do support multiple levels well as well as Layered Grid Graphs. I feel like one of those would work well here since they’re separated along the Z axis, since I can’t personally think of a way to squeeze more out of just standard Grid Graphs.

Sounds good I really the responses. I have figured a way to make it but more efficient I will post my changes soon

1 Like

Awesome, looking forward to it :smiley: