lundi 9 décembre 2019

Random.Range generates same number every repeat, how to change that

I want to do the most simple thing. Spawn enemies in 5 different lanes, constantly at random times. In this system, it picks a random number, and then at every repeat uses that same number.

    void Start()
    {
        InvokeRepeating("spawnRoad", 0, 0.5f);
        InvokeRepeating("laneOne", 0, Random.Range(1, 4));
        InvokeRepeating("laneTwo", 1, Random.Range(1, 4));
        InvokeRepeating("laneThree", 1, Random.Range(1, 4));
        InvokeRepeating("laneFour", 1, Random.Range(1, 4));
        InvokeRepeating("laneFive", 1, Random.Range(1, 4));
    }

I tried moving Random.Range into update so it would maybe constantly generate a new number into the float that the invokes used, but that just made them all invoke once at the same time and then nothing after that.




Aucun commentaire:

Enregistrer un commentaire