Spawning Objects in Unity without the Clutter
How one can control the clutter of enemies — when Player died there should be process that will stop instantiating enemies and clean the game view
This again can be done through communication between Player and Spawn Manager Scripts.
With said that Player script should have a logic of finding the GameObject and then getting the ref using GetComponent<T> where T : Spawn Manager and call onPlayerDead() method which is defined inside the SpawnManager script — when Player died — Stop Spawning enemies.
Below Game view show enemies instantiating after a regular interval of 5sec. Player have 3 lives, as player hit by enemy one by one — reducing lives to 0, one can see that enemies no longer instantiating now..stopping the clutter of enemies and cleaning the GameObjects.
@GameDevHQ-Day 12…