Grid Graph with 700 agents using 30% CPU extra

Hi there,

I have been doing some tests on my servers and I have found that 700 AILerp agents (monsters) cost me about 30% CPU usage.

My game is 2D top down and I have the pro version.

Here is the htop screenshot from before disabling AILerp (around 76% CPU usage)

And here is the same build but disabling AILerp component on the Enemy prefab

Here are the Seeker + AILerp configs

Here is my A* config

Is there anything else I can do to greatly decrease CPU usage? I dont want to spend 30h tweaking things to get 1% back, but maybe there are some simple/quick things I can do to get some of that CPU juice back.


Have you taken a look here:

Yes, all of that has been taken into account which is why I upgraded from free to pro version (in order to be able to use multithreading)


Instead of htop I would suggest using the Unity profiler to more accurately be able to determine what is using the CPU power in your game.

Here is the profiler screenshot with around 200 monsters roaming.

A bit more detailed


It looks like you have some spikes when all agents try to recalculate their paths at the same time. You could avoid this by either:

  1. Spawn the agents not at the same time, but delay each agent by a random amount (up to a second or so)
  2. Tweak the AILerp.repathRate field a tiny bit (e.g. multiply by a random value between 0.95 and 1.05) for each agent. This will quickly break up the pattern and smooth out the framerate.
1 Like