Im trying to make a object pooling system for my WaveSpawner.
This is what I got (objectPool is a 2D array):
objectPool = new GameObject[wave.Length,0];
//set columns
for(int i = 0;i< objectPool.Length;i++)
{
objectPool = new GameObject[i,wave[i].numberToSpawn]; //set row for ech column
}
for (int p = 0; p < wave.Length; p++)
{
for(int i = 0;i<wave[p].numberToSpawn;i++)
{
GameObject gbj = Instantiate(wave[p].spawnObject);
gbj.transform.position = RandomizePositions();
gbj.SetActive(false);
objectPool[p,i]= gbj; //fill 2D array
}
}
Thats the Error I got;
Array index is out of range.