Can anyone help me with a Enemy spawning system that has time on it?
I also wants to make it so that only a certain amount of enemy’s will be in game, so when i kill 1 another one will spawn. No round system please. sorry for bad english
Oky, there are quite a few ways of doing everything you need to be done.
I assume you want spawn an enemy every few seconds or so. You can do this by creating a Coroutine
private int totalEnemies;
void Start()
{
totalEnemies = 0;
StartCoroutine(SpawnEnemy);
}
void SpawnEnemy()
{
while(true){
yield return new WaitForSeconds(10);
if (totalEnemies < 5)
{
//Spawn the enemy
totalEnemies++;
}
}
}
This will call the SpawnEnemy method every 10 seconds.
It will also check the total amount of enemies currently spawned and make sure it doesn’t spawn more than 5. You will just need to decrement the totalEnemies variable every time you kill an enemy.
You can also just Google for a Unity Timer. There are hundreds available.