Using NavMesh in a mobile game. PERFORMANCE!

Has anyone Unity’s NavMesh system in a mobile game. I am using it in my game and it seems to use a lot of performance. Once I disable it and then run the build on my phone it runs very smooth. ( FYI -I am using a current-gen Samsung phone with 4GB RAM )

how many agents are you using at once are you recalculating the path every frame? How many tris in the nav mesh itself?

One Mesh per platform. But as the player moves forward new platforms are spawned using a pooling system. All of these platforms have navmeshes . Yes the nav mesh is intended to calculate the path to a moving object(player character). Player is moving so I guess it has to calculate path every frame.

I know this is a bit old but you really don’t have to update every frame.

The average reaction time for humans is 0.25 seconds to a visual stimulus, 0.17 for an audio stimulus, and 0.15 seconds for a touch stimulus.

So at 60 fps there’s ~0.1667 between each frame. Lower the path updates to every 30 frames and you’re at 0.033. So you really only need to update 4 times a second to make it believable enough.

But to be more responsive you can take anything between 4 and 60 and you’ll still perform a lot better.

You should only be calculating a new path if the agent is actually lost without a path. So this can be anything from 1 second to 1 minute.

Local actions should use regular movement as this isn’t calculating much at all.

Finally, it makes a lot of sense that you restrict or queue how many paths you can calculate per frame. For my game, it is usually one every so often, even with 10 agents. Doing it even at a frequency of 0.25 seconds is just not reasoning about if it needed a new path or not. Tis lazy :smile: