2D project requires large grid graph, advice required



I’m working on a 2D PC project that requires a large grid graph(ideally 256x512). It will be an RTS and requires formations so I’m hoping to use RVO to help this along. I have updated to the latest 4.1 at time of writing.

Procedurally generating the map runs well. Within Unity, with one unit and no other logic than click to move, it runs at less than a frame a second. I’ve started looking into breaking the grid graph up into 8 squares but I’m wondering if theres a better way? If anyone has any advice that might help, I’d greatly apreciate it.

Cheers Wilko



Less than one frame per second? That sounds odd. I can easily run a 250*500 grid graph with one agent at over 400 fps in the unity editor. Could you check the Unity profiler to see what is using all that CPU power?

I recommend using a single grid graph. Using several smaller ones will not bring you any benefits in this case.

You might also want to check out the rts beta I uploaded a while ago. You can find it by going to https://www.arongranberg.com/astar/download, click on the ‘Show Older Versions’ button and downloading the one named ‘rts beta’. It has a work in progress example scene for an RTS with some improvements to the local avoidance to work better in an RTS game.

If you have a lot of units a 256x512 graph may be a bit large as the paths can take quite some time to calculate. You may want to consider using a recast graph together with navmesh cutting instead if this turns out to be a problem.


Thanks for the help. Looks like Unity is acting up as the EditorOverhead is taking up about 90%. The problem is also the same when running the Grid Graph Sample scene which should run easily. There’s quite a long thread with people and similar issues with recent releases of Unity.

I’m using a 2D Tilemap for collisions, is that going to work with a recast graph?


No, the recast graph currently has no support for 2D colliders.


Im creating the tilemaps procedually so what if i constructed a flat 3d mesh just for the pathfinding and added a collider (or something) component to it to help construct a recast graph?


That could work, yes.


Great thanks, will give it a go.


The issue was the ‘Show Graph’ setting was on while I ran the game. Turned that off and the frame rate went back up to 100 from 1.