- Home /
How to create an enemy wave system?
Hi,
I want to create a FPS game where enemies spawn in waves... so the first wave there might be 2/3 enemies, second wave 5/6 enemies and so on, where the enemies also get harder.
I have created 3 times of enemies for now using cubes, spheres and cylinders
I have a system now where when you walk passed a certain area, enemies spawn from spawn points I have placed.
Can someone point me into the right direction on how to go about this spawn and wave system please. I have looked through numerous websites and youtube videos but Im not too sure how to do this. Im coding isnt very advanced
Here is my current code: using UnityEngine;
using System.Collections;
public class EnemySpawnController : MonoBehaviour {
public static EnemySpawnController Instance;
public GameObject Enemy;
public GameObject EnemyTwo;
public float spawnArea = 1.5f;
void Awake() {
Instance = this;
}
public void SpawnEnemies() {
//Array
GameObject[] enemySpawnSystem = GameObject.FindGameObjectsWithTag("EnemySpawnPoint");
//loop to create enemies
int i = 0;
foreach(GameObject spawnPoint in enemySpawnSystem)
{
int noEnemies = Random.Range(1,4);
for (int j= 0; j < noEnemies; j++)
{
i++;
GameObject enemy;
enemy = Instantiate(Enemy, new Vector3(spawnPoint.transform.position.x + Random.Range(-spawnArea, spawnArea),
spawnPoint.transform.position.y + Random.Range(-spawnArea, spawnArea),
spawnPoint.transform.position.z + Random.Range(-spawnArea, spawnArea)),
spawnPoint.transform.rotation) as GameObject;
enemy.name = "Enemy"+i;
}
}
}
}
Comment