Skip to content
Permalink
07bb02fdb8
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
58 lines (51 sloc) 1.61 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner1 : MonoBehaviour
{
//spawner from spaceshooter
public GameObject hazard;
public int hazardCount;
public float spawnWait;
public float startWait;
public float waveWait;
public Transform spawnhere;
//start the courotine right away
void Start()
{
StartCoroutine(SpawnWaves());
}
//start spawning
IEnumerator SpawnWaves()
{
yield return new WaitForSeconds(startWait);
while (true)
{
//setup to handle multiple enemies
for (int i = 0; i < hazardCount; i++)
{
//First Enemy
if( i == 0)
{
Quaternion spawnRotation = Quaternion.identity;
yield return new WaitForSeconds(spawnWait);
Instantiate(hazard, spawnhere.position, spawnRotation);
}
//Second Enemy
if (i == 1)
{
Quaternion spawnRotation = Quaternion.identity;
Instantiate(hazard, spawnhere.position, spawnRotation);
yield return new WaitForSeconds(spawnWait);
}
if (i == 2)
{
Quaternion spawnRotation = Quaternion.identity;
Instantiate(hazard, spawnhere.position, spawnRotation);
yield return new WaitForSeconds(spawnWait);
}
}
yield return new WaitForSeconds(waveWait);
}
}
}