using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackerSpawner : MonoBehaviour
{
bool spawn = true;
[SerializeField] Attacker attackerPrefab;
[SerializeField] float waitTimeMinimum;
[SerializeField] float waitTimeMaximum;
// Start is called before the first frame update
IEnumerator Start()
{
while(spawn)
{
yield return new WaitForSeconds(Random.Range(waitTimeMinimum, waitTimeMaximum));
SpawnAttacker();
}
}
void SpawnAttacker()
{
Instantiate(attackerPrefab, new Vector3(8, Random.Range(1,6), 0), Quaternion.identity);
}
// IEnumerator spawnOcto()
// {
// }
// Update is called once per frame
void Update()
{
}
}
It works just fine and spawns the enemies in random positions exactly like the video but without having to make seprate instances of the same object