Spawn rate not matching the values
Hello, i'm currently following the space shooter tutorial and i've just finished implementing the spawn wave system. But i've noticed that my spawn rate seemed way lower than the one in the tutorial for the same values. The code is as follows :
IEnumerator SpawnWaves (){ while (true) { for (int i = 0; i < hazardCount; i++) {
yield return new WaitForSeconds (startWait);
Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
Quaternion spawnRotation = Quaternion.identity;
Instantiate (hazard, spawnPosition, spawnRotation);
Debug.Log (Time.time);
yield return new WaitForSeconds (spawnWait);
}
}
yield return new WaitForSeconds (waveWait);
}
And i was right. After debugging the spawn time of each asteroid, I observed that if i input say 0.5 for spawnWait to spawn 2 asteroids per second, they will actually spawn at a 1.5s interval. Likewise, if i input 0.2, it will be a 1.2s interval, etc... and if i try to input a three digits number like 0.01 the interval will never go below 1s. How do i get around this ? Have i done something wrong ? I copied the tutorial's code and it works fine in the video.