OnTriggerEnter Bad Performance - Bad Code?

I have the following script set up to deploy AI cars from a pool of 13. Each trigger has an array of spawn points, which are just empty objects.

Currently I only have one trigger set up and when the player triggers it, there is a very noticeable pause. Is my code that horrific?

As I said, the array of cars is only 13. I don’t get why there is this pause because before I was drawing from a pool of 13 inactive cars, I had it hardcoded with over 100 cars in the scene and it was working flawlessly… not sure how this “optimising” managed to lower performance.

I’m not the greatest coder by any means (I’m quite crap, actually), so any insight into what I have done incorrectly would be amazeballs :wink:

#pragma strict

var SpawnerArray : GameObject[]; // Assign Spawners in inspector
var AICarArray : GameObject[]; // Assign cars in inspector

var iRandom : int = 0;
var iRandom2 : int = 0; 
var iIndex : int = 0;

function OnTriggerEnter(Other : Collider)
{
	if (Other.tag == "Player")
	{
		iRandom = Random.Range(0, SpawnerArray.Length);
	
		for (var i = 0; i < iRandom; ++i)
		{
			iRandom2 = Random.Range(0, AICarArray.Length); 
			iIndex = iRandom2;
			
			if (!AICarArray[iIndex].active)
			{
				AICarArray[iIndex].transform.position = SpawnerArray*.transform.position;*

_ AICarArray[iIndex].transform.rotation = SpawnerArray*.transform.rotation;_
_
AICarArray[iIndex].SetActive(true);_
_
}_
_
}_
_
}_
_
}*_

It doesn’t look wrong, I’d check if the problem is in another script attached to your cars