How would I select a random enemy from an array index. So far I have made this script that spawns all enemies from the array, instead of picking one random enemy from the array.
I can post more code if needed.
Code:
for(int i = 0; i < EnemyPrefab.GetLength(0); i++)
{
Vector3 offset = Random.onUnitSphere;
// Setting a value
offset.z = 0;
// Setting a value
offset = offset.normalized * SpawnDistance;
// Instantiating the Gameobject
GameObject go = (GameObject) Instantiate(EnemyPrefab[i], transform.position = offset, Quaternion.identity);
}
↧