Open World + Recast Graph: Need for optimization


We have an open-world game that has both indoor and exterior areas that all connect together. We are using a single Recast Graph for the whole 1sqkm area.

The graph is pre-scanned and stored into a graph file. Then loaded from the file during startup. This causes crashing for some players.

Another issue that we are having is that if we reduce the graph resolution, it will no more work properly in the indoor areas since walls have a lot of 90 and 180 degree corners which the agents try to cut. The walls may not be very thick - and cannot be thick in many parts of the buildings. We also have pretty tight (realistic) doorways so we cannot increase agent radius a lot.

Previously we tried splitting this one large Recast graph into multiple graphs to get better controllability and reduce the possibility of crash during loading. This didn’t work since we could not get the graphs properly connected to each other (and Aron the A* developer told us that we should use a single graph instead). If there would be a proper way to merge two or multiple Recast graphs together in runtime as they get loaded, this could help us a little.

How could we overcome these issues? Thanks.

What kind of crashes are you getting?

The whole game crashes when loading the graph. We get no info about the crash into the Player.log unfortunately. Just a permanent freeze and Windows tells our players that the game has crashed. We have about 300 alpha testers (and 15k demo testers), and mostly this is happening for those who have only 16 GB of RAM.

This doesn’t happen when the players disable the NavMesh functionality (i.e. do not load the navmesh at all). We have added this feature to our settings just to make sure that the crashing is indeed caused by A* Pathfinding Project.

We are 100% sure that this happens during the loading phase since we have added logging all over the game code (incl. navigation) and get no logs for i.e. path calculation.

Hmm. Well, unfortunately it is really hard to debug unless there is some stacktrace or another indication of what is going on.

You could also try the beta version since it might have been fixed there: A* Pathfinding Project


Could you elaborate on the other issues related to splitting the navmesh and/or improving indoor+outdoor navigation together? Since currently the navmesh is rather large and we still keep seeing NPCs getting stuck on walls since they try to go through them.

I think you should keep a high resolution if that is what is required to get a good navmesh even indoors.

Have you been able to replicate the crashes locally?

Unfortunately no, we haven’t. The crashing seems to happen for maybe 1/10 of our testers and I’ve came into the conclusion that it might be an out of memory issue during the graph loading.

That is why we don’t want to increase the graph resolution because then it will take even more memory.

Do you have a screenshot of your graph? A recast graph shouldn’t use that much memory. Also, what is the size of the serialized navmesh?

The serialized navmesh (graph.bytes file) is around 26MB.

I cannot currently check the memory allocations or take a screenshot but I will come back with these tomorrow. If you get any ideas on any other improvements, it would be greatly appreciated. Thanks.

1 Like

Is there any way to increase Recast Graph resolution for a certain smaller area only? We would like to increase the resolution for indoor areas and leave outdoor areas as is.

Sorry. That is not possible. It’s not trivial to add since it will break some invariants that are required to make different tiles connect nicely to each other.

Did you find anything interesting?