Hi! I wanted to know how to make hordes. For example, first horde 2 enemies and the next horde the same enemies multiplied by 1.5.
Thanks.
P.D: Sorry for my English.
Hi! I wanted to know how to make hordes. For example, first horde 2 enemies and the next horde the same enemies multiplied by 1.5.
Thanks.
P.D: Sorry for my English.
This is actually pretty easy to do with a for loop
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HordeSpawner : MonoBehaviour {
public GameObject hordeCharacter; //Horde character prefab
public Transform hordeSpawnTransform; //Spawn location of your horde
public int enemyCount = 2; //Starting horde count
public int hordeGrowRate = 2; //Change this when you want to multiply by a bigger value
public static List<GameObject> enemiesInLevel = new List<GameObject>(); //A list of enemies that are currently in your level, just remove one whenever you kill one
public void SpawnHorde()
{
enemyCount = enemyCount * hordeGrowRate;
for (int i = 0; i < enemyCount; i++)
{
GameObject go = Instantiate(hordeCharacter, hordeSpawnTransform.position, hordeSpawnTransform.rotation); //Spawning of your enemies
enemiesInLevel.Add(go); //Adding your enemy to a list so you can access them in other scripts remove this if you don't a list of your enemies
}
}
}
Added a list in this script so you can keep track of your enemies but you can remove it if you don’t want that.