Navmesh Agent make big performance impact

185512-screenshot-7.png

185513-screenshot-8.png

First Image show when i enable 15 navmesh agent the fps was 80-90. Agents are simple they just go one point to another point

Second Image show when i disable 15 navmesh agent the fps was 270 to 300. Why?

Please help me out.

Navmesh agent Scrip ----------------

public class AIControl : MonoBehaviour {

GameObject[] goalLocations;
NavMeshAgent agent;
private Animator anim;

private void Awake()
{
	anim = GetComponent<Animator>();
	goalLocations = GameObject.FindGameObjectsWithTag("goal");
	agent = this.GetComponent<NavMeshAgent>();
}

// Use this for initialization
void Start () {
	agent.SetDestination(goalLocations[Random.Range(0,goalLocations.Length)].transform.position);
	anim.SetFloat("wOffset", Random.Range(0,1));
 	anim.SetTrigger("isWalking");
}

// Update is called once per frame
void Update () {
	if(agent.remainingDistance < 1f)
    {
		agent.SetDestination(goalLocations[Random.Range(0, goalLocations.Length)].transform.position);
	}
}

}

You should exclude animation and model consumption first.Avoid the influence of other factors on the results

From the picture, your rendering thread time-consuming has also doubled

I concur with James, there seems to be more influencing it here. I assume if you’re enabling 15 different characters they all seem to be getting drawn at the same time (+ 600k tris etc).
There are a few things you could do.

  1. Put characters on a different layer,
    and use
    Unity - Scripting API: Camera.layerCullDistances
    to only draw them when in closer
    range (Using methods that do not
    draw the characters at all when not
    needed will give the biggest boost)
  2. Use lower poly versions of far away
    characters.
  3. Reduce the NavAgent.Quality of
    characters, especially if far away
  4. Do not update scripts or components
    that are not needed (hard to say
    without seeing your game code) when
    not needed.