- Home /
Enemy Spawn System with time and limit enemy in game
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
i have searched for about 2 days now. cant find anyting usefull and btw most is in java. Also i cant write my own scripts because i'm new to that.
Yes I need it to spawn enemys for about every 10 second and not more than about lets say 20 in game. and only spawn to the nearest 4 spawnpoint, because i want to make a big map and if the enemys spawn at the other side of the map it will take forever to fnd them.
so if anyone can help me or find something on google please reply. maybe in return i can make some models for you
In my opinion, you need to go through the tutorials that Unity has to offer. Learning to code and create games doesn't happen overnight. I studied computer science for 4 years and from the beginning of this year I have been learning Unity. Obviously the 4 years aren't necessary but it did help me start off a lot quicker.
Here is a live training session given by people working for Unity on how to start coding: https://unity3d.com/learn/tutorials/topics/scripting/coding-unity-absolute-beginner
Here is a 4 hour video on learning ALL the basics of C# with Unity: https://www.youtube.com/watch?v=7gX-$$anonymous$$26Oj1Y
Here are all the tutorials created by Unity: https://unity3d.com/learn/tutorials
Believe me, if you go through all of this you would definitely be able to make a game. You need to put in some time first before you can create a great game.
Hope this helps, and good luck.
Answer by CBRZY · Sep 23, 2016 at 01:09 PM
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
https://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html
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.
Your answer
Follow this Question
Related Questions
How to prevent multiple spawns from a single spawn point? 1 Answer
Random spawnpoint where only one prefab can spawn! 1 Answer
How to spawn enemies at different locations and avoid overlapping each other 2 Answers
SPAWNING ENEMIES and controlling the amount/interval 1 Answer
How do I add multiple different enemies to a wave spawner? 2 Answers