Extreme lag with 30+ actors

Firstly I LOVE the package, I am almost 100% going to buy it once I flush out some issues I am having.

I am making a zombie game just to mess around with the pathfinding and have a ‘Target Position’ that the zombie actors are attempting to get too.

I have lightweight zombie actors that launch their own thread which updates every 2 seconds.

IEnumerator MoveToTarget(float waitTime) { while(true) { seeker.StartPath (transform.position, TargetPosition.position, OnPathComplete); yield return new WaitForSeconds(waitTime); } }

Then their ‘FixedUpdate’ uses the same code from your simple tutorial.

public void FixedUpdate ()

	if (path == null) {
		//We have no path to move after yet
	if (currentWaypoint >= path.vectorPath.Count) {
		Debug.Log ("End Of Path Reached");
	//Direction to the next waypoint
	Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized;
	dir *= speed * Time.fixedDeltaTime;
	controller.SimpleMove (dir);

	//this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Quaternion.LookRotation(path.vectorPath[currentWaypoint]), 3.0f);
	Debug.Log (path.vectorPath[currentWaypoint]);

	//Check if we are close enough to the next waypoint
	//If we are, proceed to follow the next waypoint
	if (Vector3.Distance (transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) {


Fairly straight forward, no messy computation. The problem is when calculating a new route, there is EXTREME lag when I have 30 zombies or so on the scene. Is this just a limitation of this project or is there something wrong with the way in which I am re-calculating the paths? I wanted to make a game with atleast 40/50 zombies on the scene at the same time but with this lag it struggles with 20.

Note that there are also other problems when some actors wont even calculate their paths and will just ‘Path fail’ for some ticks until it works all of a sudden… I am guessing this is related to your method of queuing paths?


It really shouldn’t struggle with 30 characters. How large is your graph?
And make sure to disable “Show Graphs” if you are testing in the editor since that can be really slow.

Hi Aron :slight_smile:

100x100 Grid, similar to your tutorial… here is an image with the settings

also here is my modifier settings:

Because of how long it takes the first 20 zombies to re-calculator their paths, the other 20 never actually move, because their paths take like 5+ seconds to get through the queue and by that time their path has already been re-set with the seeker.StartPath… :frowning: Do you have any tutorial scene with large amounts of actors that can follow?

Ok so I ditched my own code and just added your AIPath(Generic) script and the performance has improved tons… gonna use that instead haha