Created
September 17, 2021 03:13
-
-
Save curious-username/11ccd7c6a2085ed07150ea08e94195fe to your computer and use it in GitHub Desktop.
spawn manager for kitty loaf shooter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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