I came so close. and then finished

Dang. While(true) who would of thought of that lol.
i got as far on my own to be able to spawn the enemies but only in an update every once per frame.
then i tried writing an if statement in the update but you just cant do it through update. i didnt want help so i skipped into the video to the part that i didnt know how to do and after he coded the While (true) part and explained i stopped watching the video and did the rest myself. i advise other people that might get frustrated to do the same. watch small clips of the video an stop yourself and try it. it helps me alot.

public class EnemySpawner : MonoBehaviour
{

    [SerializeField] GameObject EnemyShips;
    [SerializeField] float timeBetweenSpawns = 2f;


    void Start()
    {
       StartCoroutine(RunSpawner());
    }

    IEnumerator RunSpawner()
    {
        while (true)
        {
            GameObject enemy;
            enemy = Instantiate(EnemyShips);
            yield return new WaitForSeconds(timeBetweenSpawns);
        }
    }


}
1 Like

Awesome tip I’ll try it next time I get stuck!

Privacy & Terms