Optimizing Updates path finding on recast graphs

I’m looking to optimise my game and the big perfomance cost I have currently is the graph update that happens at an interval ( not every frame) . I’m using a recast graph. Hoping to replace this with local avoidance but this is the solution I reverted to when it was disabled. As the game is currently live in the app store I want to be somewhat careful and avoid major refactoring.

Here is a screenshot from the profiler in unity:

Do you have any advice on on how to optimise the graph update and path finding when using recast graph?




Try the latest version.
3.7.1 has this in the changelog:

Improved performance of loading and updating large recast graph tiles (improved performance of internal AABB tree).

Looking at the profiler output I think this will give your code a big performance boost since most of the time is spent in BBTree.Insert.

Additionally you can try to use smaller tiles, that can help if you only update a small portion of the tiles at a time.

Cheers thanks for the quick reply, I’m trying with the new version and I seem to loose the graphs. Is there are way to maintain these when updating? When trying to load a cached graph i get this error: “The data is either corrupt or it was saved using a 3.0.x or earlier version of the system”


Hm. What version did you upgrade from?
Did you use any preprocessor directives with the previous system? (like mentioned on http://arongranberg.com/astar/docs/iphone.php)
I try to make sure that graph settings can always be upgraded, however graph data cannot always be upgraded cleanly. But that data can always be recalculated in the editor so then no harm is done.

I’m upgrading from 3.6 and the “optimisations” I have enabled are:

NO_ZIP (suspicious considering the error, if I remember correctly this was enabled due to issues with 64bit iOS )

Ok that makes sense.
Previously preprocessor directives were stored directly in the source files, so when you upgraded they would be lost. I have changed that now so that they are instead stored in the Unity player settings. So before you upgrade add ASTAR_NO_ZIP to the preprocessor directives in the Unity player settings and then I think it will work.

They might be called scripting define symbols in the player settings.

Awesome, that seems to have fixed it…I’ll take it out for a spin when I get back home!

Thanks! :smile: