IEnumerator CreateAsteroids()
{
// Loop forever
while (true) {
// Work out when the next asteroid should appear
float nextSpawnTime = spawnRate + Random.Range(-variance, variance);
// Wait that much time
yield return new WaitForSeconds(nextSpawnTime);
// Additionally, wait until physics is about to update
yield return new WaitForFixedUpdate();
// Create the asteroid
CreateNewAsteroid();
}
}