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

Anurag Chawla
Apr 9, 2021

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.

Script Communication between Player and SpawnManager

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.

Hierarchy Window shows — Stop clutter of enemies when Player Died..

@GameDevHQ-Day 12…

--

--

Anurag Chawla
Anurag Chawla

Written by Anurag Chawla

Emerging Technologies - Power Virtual Agents | AI Chatbots | Multi-Cloud & DevOps | UI Technologies - React , Angular | Gaming Technolgies - Unity, XR- AR/VR

No responses yet