- Home /
Instantiate stop when all of them have destroyed
hallo guys, i have a problem here. i use instantiate for cloning the enemy at random place. the player can shoot the enemy and it will be destroyed. enemy will spawning every 3 second. but if the player shoot all the enemy before next 3 second, enemy will not spawning again. what happen to my enemy? i want to make them keep spawning every 3 second. please help me. anyone can answer what happen to my game?
Where do you call Instantiate() function? If it is in scripts attached to enemy object, you should put it in script, which will not be destroyed during play time. Other moment: if your coroutine implemented in script attached to enemy it will stop working if enemy was destroyed. I can provide you more help if you show some code snippets with calling Instantiate() and coroutine
Answer by jovino · Apr 03, 2014 at 11:19 AM
Yo need to Instatiate a prefab, not a scene gameobject, that is: you have to reference an "object" in your project window, not one in the scene.
Anyway, try to learn about pooling, take a look here for example : http://answers.unity3d.com/questions/321762/how-to-assign-variable-to-a-prefabs-child.html
Your answer
Follow this Question
Related Questions
Can't seem to destroy instantiated objects. 1 Answer
Can a Network.Instantiate()'d object be Object.Destroy()'d? 0 Answers
Checking Instantiate/Destroy has been called | Checking number of scene GameObjects 1 Answer
Destroy last placed object and put a new one? 1 Answer
Proper/Best way to Instantiate and Destroy with Unity Networking? 2 Answers