Skip to content

Instantly share code, notes, and snippets.

@curious-username
Created September 17, 2021 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curious-username/11ccd7c6a2085ed07150ea08e94195fe to your computer and use it in GitHub Desktop.
Save curious-username/11ccd7c6a2085ed07150ea08e94195fe to your computer and use it in GitHub Desktop.
spawn manager for kitty loaf shooter
public class SpawnManager : MonoBehaviour
{
[SerializeField]
private GameObject _enemyPreFab;
private bool _stopSpawning = false;
// Start is called before the first frame update
void Start()
{
StartCoroutine(SpawnEnemy());
}
// Update is called once per frame
void Update()
{
}
IEnumerator SpawnEnemy()
{
while (_stopSpawning == false){
Vector2 spawn = new Vector2(Random.Range(-4.7f, 4.7f), 5);
Instantiate(_enemyPreFab, spawn, Quaternion.identity);
yield return new WaitForSeconds(3);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment