Spawning a wave of asteroids

Im trying to spawn a wave of asteroids on a 3D plain

the 1st block of code spawns 1 asteroid and that works fine

using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour
{
public GameObject hazard;
public Vector3 spawnValues;

void Start ()
{
	SpawnWaves ();
}

void SpawnWaves ()
{ 
	Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
	Quaternion spawnRotation = new Quaternion ();
	Instantiate (hazard, spawnPosition, spawnRotation);

}

}

This block is meant to spawn multiple asteroids, but nothing happens when I test it.
The Asteroid clone doesn’t appear in the hierarchy when I test it so i know it’s not being destroyed by the boundary.
No errors appear in the console.

If anyone has any suggestions please let me know

using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour
{
public GameObject hazard;
public Vector3 spawnValues;
public int hazardCount; //count number of times it goes through the loop
public float spawnWait;
public float startWait;
public float waveWait;

void start ()
{
	StartCoroutine (SpawnWaves ());
}

IEnumerator SpawnWaves ()
{ 
	yield return new WaitForSeconds (startWait);
	while (true) //infinate loop
	{
		for (int i = 0; i < hazardCount; i++) 
		{
			Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
			Quaternion spawnRotation = Quaternion.identity;
			Instantiate (hazard, spawnPosition, spawnRotation);
			yield return new WaitForSeconds (spawnWait);
			
		}
		yield return new WaitForSeconds(waveWait);
	}
}

}

Hi,

Did you assign the “hazard” GameObject in unity ?

You can maybe try by loading the GameObject from a “Resources” directory in the script like that :

Instantiate (Resources.Load ("Meteor"), spawnPosition, spawnRotation) as GameObject;