How to change speed for a cloned prefab instead of applying it to all instances of prefab?


I have a NavMeshAgent that loops around a path. The Prefab has a tag set to “car”. I can make an instance of the prefab by pressing a button. The prefab has a box collider which acts as trigger sensor (this was a quick implementation to determine if anything is in front of the prefab).

In my code I have the trigger box detecting if there’s a car colliding with it that it shoudl stop before the mesh of the prefab collides with whatever is in front of it, and then resume after the car in front is not in the trigger zone.

private void OnTriggerEnter(Collider other){
		switch (other.tag){
		case "car":	// if there's a car obj in front, stop

	private void OnTriggerExit(Collider other){
		switch (other.tag) {
		case "car":
			agent.Resume ();

My issue is that if I spawn 2 of my NavMeshAgent with a bit of a delay in between, if the last spawned agent detects the other object in its trigger box zone, it will stop (as intended) but the agent that in front of it will also stop. How do I make it so that only the object behind the navmeshagent is only affected and not all instances of the prefab?


Quick comment; In the title I wrote that I want to change the speed, this is a typo on my end. I meant to say how do I prevent all instances of a NavMeshAgent from stopping.