- Home /
Question by
Thormouse · Sep 05, 2019 at 02:35 PM ·
enemy spawn
How do i get this code to spawn a boss after a certian amount of waves?
public class EnemySpawnerController : MonoBehaviour { public GameObject EnemyPrefab; public Vector2 SpawnValues; public int EnemyCount; public float EnemyWaitTime; public float startEnemyWait; public float waveWait; private void Start() { StartCoroutine (SpawnWaves()); }
IEnumerator SpawnWaves()
{
yield return new WaitForSeconds(startEnemyWait);
while (true)
{
for(int i = 0; i < EnemyCount; i++)
{
Vector2 spawnPosition = new Vector2(Random.Range(-SpawnValues.x,SpawnValues.x)-SpawnValues.y,SpawnValues.y);
Quaternion spawnRotation = Quaternion.identity;
Instantiate(EnemyPrefab,spawnPosition,spawnRotation);
yield return new WaitForSeconds(EnemyWaitTime);
}
yield return new WaitForSeconds(waveWait);
} } }
Comment
Answer by cameronb_unity287 · Sep 05, 2019 at 02:49 PM
if you can make a counter for the waves using code, then you can plugin the wave counter to the boss spawner, so in code say after said amount of waves spawn the boss.
Your answer
Follow this Question
Related Questions
enemy wave spawn script wont work 0 Answers
Add a enemy to list and check min distance 0 Answers
Enemy clone not following script 1 Answer
Spawnerscript only spawns 5 enemy 2 Answers