Comments

Log in with itch.io to leave a comment.

(+2)

If you only need the script:

using UnityEngine;

using UnityEngine.UI;

[System.Serializable]

public class Wave

{

    public string waveName;

    public int noOfEnemies;

    public GameObject[] typeOfEnemies;

    public float spawnInterval;

}

public class WaveSpawnner : MonoBehaviour

{

    public Wave[] waves;

    public Transform[] spawnPoints;

    public Animator animator;

    public Text waveName;

    private Wave currentWave;

    private int currentWaveNumber;

    private float nextSpawnTime;

    private bool canSpawn = true;

    private bool canAnimate = false;

    

    private void Update()

    {

        currentWave = waves[currentWaveNumber];

        SpawnWave();

        GameObject[] totalEnemies = GameObject.FindGameObjectsWithTag("Enemy");

        if (totalEnemies.Length == 0  )

        {

            if ( currentWaveNumber + 1 != waves.Length )

            {

                if ( canAnimate)

                {

                    waveName.text = waves[currentWaveNumber + 1].waveName;

                    animator.SetTrigger("WaveComplete");

                    canAnimate = false;

                }

                

            }

            else

            {

                Debug.Log("GameFinish");

            }

        }

        

    }

    void SpawnNextWave()

    {

        currentWaveNumber++;

        canSpawn = true;

    }

    void SpawnWave()

    {

        if (canSpawn && nextSpawnTime < Time.time)

        {

            GameObject randomEnemy = currentWave.typeOfEnemies[Random.Range(0, currentWave.typeOfEnemies.Length)];

            Transform randomPoint = spawnPoints[Random.Range(0, spawnPoints.Length)];

            Instantiate(randomEnemy, randomPoint.position, Quaternion.identity);

            currentWave.noOfEnemies--;

            nextSpawnTime = Time.time + currentWave.spawnInterval;

            if (currentWave.noOfEnemies == 0)

            {

                canSpawn = false;

                canAnimate = true;

            }

        }

        

    }

}

thanks

(+5)(-1)

why the faq u cant just copy the script

(+1)(-1)

DANI