Spawn Controller

Purchase the Plugin from the Unity Asset Store.

Drag and Drop the Prefabs “SpawnController” (just once) and “Spawner” (as many as needed) into the Hierarchy. Use the Prefab SpawnController to setup your Waves, the Spawning positions (by selecting the Spawner’s you set up in the Hierarchy), and setting the Enemy(s) that will spawn from that Spawner.

An example scene is setup and ready in the Example directory.

Note: Make sure all Enemy Prefab’s used by the Spawn Controller have a unique “name”. This is important so the built in Breed plugin doesn’t break.

Note: You will most likely need to set the order of execution of scripts for this Plugin (Edit -> Project Settings -> Script Execution Order)

// specify which wave you want to start/play
SpawnController.PlayWave(int); 
 
// if possible, plays the next wave in the waves (current wave + 1 > n (waves setup in the spawn controller) = not going to happen)
SpawnController.NextWave(); 
 
// if possible, plays the previous wave in the waves (current wave - 1 < 0 (first index) = not going to happen)
SpawnController.PreviousWave(); 
 
// if "Play On Start" is not checked. Calling 'PlayWave' alone will not start the wave if it is paused
SpawnController.ResumeWave();
 
// pause the wave
SpawnController.PauseWave();
 
// adding callbacks for all the event types (beforeWave, inWave, betweenWaves, finishedLast)
SpawnController.EventAdd(SpawnStates.(state of wave), theCallbackFunction);
 
// removes the callback(s) with the specified state (beforeWave, inWave, betweenWaves, finishedLast)
SpawnController.EventRemove(SpawnStates.(state of wave));
 
// gets the current wave
Debug.Log(SpawnController.currentWave)
 
// gets the current spawn state
Debug.Log(SpawnController.spawnState)
 
// gets the total number of waves
Debug.Log(SpawnController.wavesLength)
 
// an enemy that is spawned who is about to die, needs to call this method
var spawnedEnemy : SpawnedEnemy = gameObject.GetComponent("SpawnedEnemy") as SpawnedEnemy;
spawnedEnemy.Dead();

Here are the options in the Inspector when highlighting the SpawnController from the Hierarchy

Spawn Controller Settings

Current Wave – This is the current Wave we are playing

Play Wave – The Wave to play at start

Play On Start – If checked, will start the Spawn Controller

Restart Wave At – Once the Waves finish, you may choose which Wave to restart at (or choose not to restart)

Time Before First – The amount of time before the first Wave will begin

Time Between Waves – The amount of time between each Wave

Wave Settings

Type – The type of Wave this will be: Time or Kill. If type is Time: it will spawn Enemies from the Spawners in this Wave until the time expires (note, if any of the Waves Spawners have a type of Kill, Allow Stranglers MUST be checked in order to behave properly). Once the Time expires, it will move onto the next Wave. If type is Kill: all the Enemies spawned must be killed in order to proceed onto the next Wave

Time (only if Time type) – The amount of time this Wave will last before the Wave is complete

Allow Stranglers (only if Time type) – If checked, it will continue to spawn Enemies from the Spawners even when the set Time has been passed

Spawner Settings

Type – the type of Spawner this will be: Time or Kill. If type is Time: will spawn Enemies at a set Rate until all the Enemies set within this Spawner have been spawned. If type is Kill: it will only spawn 1 (one) Enemy at a time until that Enemy is killed, before spawning the next

Endless – If checked, will continuously spawn Enemies based on the Spawner’s settings

Rate (only if Time type) – The amount of time to spawn the Enemies

Initial Delay (only if Time type) – The amount of time to delay before spawning the first Enemy of the Spawner

Delay Between Spawns (only if Kill type) – The amount of time to delay between each Enemy to spawn once the previous Enemy has been killed

Random Spawners? – If checked, will allow you to spawn Enemies from multiple Spawners

Spawner – This is a drop down of the available Spawner’s in the Hierarchy (Prefabs with the Tag name of “Spawner”). It is recommended to set the name the Spawners to their appropriate location

Enemy Settings

Repeat – The number of times this Enemy will be repeated before moving onto the next Enemy (if any)

Random Enemies? – If checked, will randomly select an Enemy from the enemies available

Enemy – This is the Enemy you wish to be spawned

Send Messages – This allows you set send messages and values to the Enemies that are spawned. For example, setting the values for one of the messages Name and Value could be: setSpeed and 5. (function name, passed value – must be a string!)