public Transform[] spawnPoints; // Array of spawn points to be used.
public GameObject[] enemyPrefabs; // Array of different Enemies that are used.
public int amountEnemies = 20; // Total number of enemies to spawn.
public int yieldTimeMin = 2; // Minimum amount of time before spawning enemies randomly.
public int yieldTimeMax = 5; // Don't exceed this amount of time between spawning enemies randomly.
private int i;
void Start()
{
Spawn();
}
public void Spawn()
{
for (i = 0; i < amountEnemies; i++) // How many enemies to instantiate total.
{
// yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax)); // How long to wait before another enemy is instantiated.
GameObject obj = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)]; // Randomize the different enemies to instantiate.
Transform pos = spawnPoints[Random.Range(0, spawnPoints.Length)]; // Randomize the spawnPoints to instantiate enemy at next.
Instantiate(obj, pos.position, pos.rotation);
}
}
}
Ошибка: NullReferenceException: Object reference not set to an instance of an object
RaycastExample.Start () (at Assets/Scripts/RaycastExample.cs:23)