mercredi 15 janvier 2020

i get any number except 1

This is the code I wrote to spawn something randomly btw two positions but it always spawns it in the "spawnpoint2" and IDK what to do

{
public Transform spawnpoint1;
public Transform spawnpoint2;
public GameObject enemyprefab;

private void Start()
{
    InvokeRepeating("spawn", 3f, 5f);
}

void spawn()
{
    float randomizer= Random.Range(0f, 3f);
    if (randomizer == 1f)
        Instantiate(enemyprefab, spawnpoint1);
    else
        Instantiate(enemyprefab, spawnpoint2);
}

}




Aucun commentaire:

Enregistrer un commentaire