How to Create a Spawn Manager in Unit
A spawn manager is an object that allows us to create objects dynamically within our game. It could be used to create enemies, powerups, collectibles and more.
In this example we’re gonna create an enemy spawn manager, the enemy gonna appear at the top of the screen and in a random horizontal position.
First we have to declare a _spawnDelay and _enemyPrefab variable and assign the prefab in the inspector view.
Then we’re gonna create a Coroutine to spawn the enemy every amount of seconds defined in the _spawnDelay variable.
Finally we have to start the coroutine in the Start() method.
And we have a functional enemy spawn manager for our game.