- Home /
delay first spawn
When I play the enemys spawn instantly from each spawnpoint then go to there normal delay time and i need a way to get rid of the first enemy spawned maybe a delay or a way to delete it.
Thankyou
var Enemy : GameObject; var DelayMin = 5.0; var DelayMax = 20.0;
 
                function Start () {
     SpawnRoutine();
 }
  function SpawnRoutine () {
     while(true) {
     Instantiate (Enemy, transform.position, transform.rotation);
     yield WaitForSeconds(Random.Range(DelayMin, DelayMax)); 
 }
 }  
Do what $$anonymous$$yth said, but Start itself can be a coroutine; you can get rid of SpawnRoutine if you like.
Answer by Myth · Jan 28, 2011 at 06:09 AM
not sure on the functionality s of yield but shouldn't it go before the instantiate?
For not being knowledgeable about them, you sure do know exactly what the problem is. ;-)
true i didn't take much notice to that but it worked.
Answer by Phil 5 · Jan 28, 2011 at 02:09 PM
I would go with something like:
var Enemy : GameObject; var DelayMin = 5.0; var DelayMax = 20.0; var TimeLeft = 50.0; //initial delay here
  
               function Update() { TimeLeft -= Time.deltaTime; if (TimeLeft <= 0.0) { Instantiate (Enemy, transform.position, transform.rotation); TimeLeft = Random.Range(DelayMin, DelayMax)); } } 
Hope it helps.
thats excellent thankyou is there any chance u could help me with possibly making the time left a random number aswell my game involves enemies spawning randomly around you thankyou
Your answer
 
 
             Follow this Question
Related Questions
Problem with the enemy 0 Answers
Trying out a unique method of spawning enemies. Someone want to help sort out the logic of it? 1 Answer
enemy wave spawn script wont work 0 Answers
Spawning Objects at location 3 Answers
Shoot Bullet Delay Enemy 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                