Now this code working only with two objects. Why?
I want created 3 levels.
Level 1 - 2 objects
Level 2 - 3 objects
Level 3 - 5 objects
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GSpawners : MonoBehaviour
{
public Transform[] SpawnerPoints;
public List<GameObject> SpawnerObjects;
public bool[] spotUsed;
void Awake()
{
Spawner();
}
public void Spawner()
{
// var rnd = Random.Range(0, SpawnerObjects.Count);
var bools = Random.Range(0, spotUsed.Length);
int spawnPointIndex = Random.Range(0, SpawnerPoints.Length);
int spawnObjectsIndex = Random.Range(0, SpawnerObjects.Count);
//while (spotUsed[spawnPointIndex] == true)
//{
// spawnPointIndex = Random.Range(0, SpawnerPoints.Length);
//}
for (int P = 0; P < bools; P++)
{
Instantiate(SpawnerObjects[spawnObjectsIndex], SpawnerPoints[spawnPointIndex].position, SpawnerPoints[spawnPointIndex].rotation);
spawnObjectsIndex++;
SpawnerObjects.RemoveAt(spawnObjectsIndex);
spotUsed[spawnPointIndex] = true;
}
}
}