예제 #1
0
    void Update()
    {
        timeElapsed += Time.deltaTime;

        if (timeElapsed >= spawnInterval)
        {
            var enemies = GameObject.FindGameObjectsWithTag("Enemy").Length;
            if (enemies >= 20)
            {
                return;
            }
            var spawnPos = RandomPosition.GetRandomPos(transform.position, spawnRange);
            var obj      = Instantiate(enemyObject, spawnPos, Quaternion.identity);
            obj.tag     = "Enemy";
            timeElapsed = 0f;
        }
    }