Day 14 — Clearing out object clutter in Unity

[SerializeField]
private GameObject _enemyContainer;
IEnumerator SpawnEnemy()
{
while(true)
{
Vector3 position = new Vector3(Random.Range(-10.7f, 10.7f), 6.2f, 0);
GameObject enemy = Instantiate(_enemyPrefab, position, Quaternion.identity);
enemy.transform.parent = _enemyContainer.transform;
yield return new WaitForSeconds(5.0f);
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Connor Fullarton

Connor Fullarton

Hey and welcome! My name is Connor and my goal here is to put out a daily post for a full year about my game development journey.