I try to spawn one or two obstacle at the same time given the position rightpos, midpos, and leftpos
but i keep getting the spawn position to only rightpos and midpos.
void Start () {
rightpos = new Vector2(2f,6f);
midpos = new Vector2 (0f,6f);
leftpos = new Vector2 (-2f, 6f);
}
// Update is called once per frame
void Update () {
if (spawn_activate == true) {
number_of_spawn = Random.Range (1, 2);
spawn_activate = false;
}
if (number_of_spawn > 0) {
spawnposition = Random.Range (0, 2);
if (spawnposition == 0) {
Instantiate(obstacle,rightpos,Quaternion.identity);
}
if(spawnposition == 1) {
Instantiate(obstacle,midpos,Quaternion.identity);
}
if(spawnposition == 2) {
Instantiate(obstacle,leftpos,Quaternion.identity);
}
number_of_spawn -= 1;
}
}