Random Enemy Instantiate

Hi guys,

I’m trying to instantiate 10 enemy prefabs like this example: At first I want to instantiate the first 3 enemies within 30 seconds, after that instantiate the 1st to the 6th enemy for a few more seconds, and so on. I’m having trouble creating an algorithm that makes it look natural and instantiate more enemies over time.

I’m using JavaScript, but just a simple pseudocode would certainly help me.

Thank you

Courintine and for loop?

Loop

http://docs.unity3d.com/Documentation/ScriptReference/index.Coroutines_26_Yield.html

The simpler way is to use a coroutine with a loop inside. In that loop you can instantiate an enemy and then use a yield new waitforseconds (mathf.random()) or the random function of your preference to wait a random amount of time before instantiating your next enemy.