Day 10: Spawning Objects in Unity without the Clutter
The goal is to create a system that instantiates new objects during the game in addition to those present at the beginning of the game.
To do this you need to create a script. The SpawnManager.
First, we need to create an empty object and its script.
Inside the script, we have to create the variables of the game objects that we want to instantiate.
Now we need to define the logic by which our objects will be instantiated. That is the position and time of when they are to appear.
We define our coroutine:
finally, we start the coroutine in the Start() method:
We save and return to Unity, now in our Inspector we can drag our prefabs and try if everything works correctly.
This should be the result.