I can’t figure out why i am getting the error cannot convert from ‘System.Collections.Generic.List<UnityEngine.GameObject>’ to ‘UnityEngine.Object’.
The error is happening on line 21 where I am instantiating enemy to a newEnemy GameObject to then add to a GameObject list.
public float waveNumber = 1f;
public List<GameObject> enemy = new List<GameObject>();
public Transform[] spawnSpots;
private float timeBtwSpawns;
public float startTimeBtwSpawns;
public float amount = 10f;
public float rate = 1.1f;
public GameObject newEnemy;
// Start is called before the first frame update
void Start()
{
timeBtwSpawns = startTimeBtwSpawns;
}
// Update is called once per frame
void Update()
{
if (timeBtwSpawns <= 0)
{
int randPos = UnityEngine.Random.Range(0, spawnSpots.Length);
newEnemy = Instantiate (enemy, spawnSpots[randPos].position, Quaternion.identity);
enemy.Add(newEnemy);
timeBtwSpawns = startTimeBtwSpawns;
if (enemy.Count == amount)
{
waveNumber++;
amount = increaseAmount(amount, waveNumber);
enemy.Clear();
}
}
else
{
timeBtwSpawns -= Time.deltaTime;
}
}
float increaseAmount(float amount, float round)
{
amount = amount * (float)Math.Pow(1.2f, round);
amount = (float)Math.Ceiling(amount);
return amount;
}