- Home /
enemy spawn and in game time counter
i need to make a enemy spawn the will spawn a new enemy after a amount of time and i need a a in game timer counter
Answer by zaid87 · Aug 25, 2014 at 04:17 AM
To spawn a GameObject, you can either create them on the spot using Instantiate or create a group of them at the start of the game, store them in a pool then use/spawn them whenever you want.
For the timer, just create a float variable and set it to the value of each spawning interval at start. Inside the Update method, minus the value with Time.deltaTime. Once the timer reaches 0 (or lower), call the code for spawning the enemy and set back the timer to its original value.
Not quite sure what you mean by "a in game timer counter", but I'm guessing something like how long have the player play the game? If yes, just use the same logic as the spawning timer except that, instead of deducting the value until it reaches 0, you start at 0 and adds the value of Time.deltaTime inside update.
Your answer
![](https://koobas.hobune.stream/wayback/20220613161441im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Enemy AI Help? 1 Answer
How to Stop Enemy "Shooting Through A Wall" 1 Answer
Script to make an enemy follow the player when they trigger a door? 0 Answers
Enemy Spawn script not continuing level 2 Answers