jeudi 3 août 2017

Random.Range not changing its outcome each time its called, why?

I am using random range to choose a between enemy types to spawn.

IEnumerator Spawn()
    {
        int randAmount = Random.Range(minAmount, maxAmount); // Determine quantity of enemies to be spawned
        int randType = Random.Range(0, 1); // Determine which enemy is spawned
        enemies[randType](randAmount); // Call enemy type, then amount
        yield return new WaitForSeconds(spawnRate);
        StartCoroutine(Spawn()); // Loop
    }

When attaching to unity with the debugger, I can see that randAmountchanges each time the coroutine is called, however the randType has not changed from 0, I have been testing over and over and I am starting to think it is no longer bad luck.

I know that the first variable is working correctly, is there anyway to ensure that the second one works correctly, or an alternative method to get a random number between 0 and 1 each time the coroutine is called.




Aucun commentaire:

Enregistrer un commentaire