Game Toolkit for Unity
Setting up the enemy spawner.
In this tutorial we’ll create a schematic spawning enemies at a randomly selected spawn point in the scene. We’ll use the schematic in 3 Auto Machines to spawn the 3 different enemies repeatedly.
First, we’ll set up the schematic. Since the spawn points we’re going to use are game objects defined in the scene, we’ll use an actor for that.
Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.
We need an actor for the spawn points and a prefab resource for the enemy prefab.
Click on Add Actor to add an actor.
Click on Add Prefab Resource to add a prefab resource. The used prefab will be defined in the machine’s prefab using resource overrides.
Add Node > Game Object > Prefab > Spawn Prefab
This node is used to spawn a prefab. We’ll use it to spawn the enemy prefab at a randomly selected spawn point (actor).
And that’s it for the schematic – click on Save Schematic and save it as EnemySpawner in Assets/Schematics/.
Select the EnemySpawner game object in the scene hierarchy, we’ll add the enemy spawner schematic to it using an auto machine. The spawn points we’re going to use are child objects of this object.
Add an auto machine component to the game object (e.g. using the component menu: Makinom > Machines > Auto Machine). Change the following settings.
Click on Add Actor Object multiple times to add 9 game object selection fields to Actor 0. Select SpawnPoint 1 to SpawnPoint 9 in the selection fields.
The game objects are child objects of the EnemySpawner game object.
Expand the Resource Overrides to change the used prefab.
Click on Add Prefab to add a prefab that will be used.
We’ll only want enemies to be spawned when the player is alive.
Click on Add Condition, we’ll set up the variable conditions here.
In the added Condition 0, we’ll set up our variable condition.
Click on Add Variable.
Copy the previous auto machine component by right-clicking on it’s name and selecting Copy Component. Add the copy by right-clicking on the name again and selecting Paste As New Component.
Change the following settings in the new auto machine component.
Again, paste the copied component by right-clicking on the name and selecting Paste As New Component.
Remove 5 of the added Actor 0 game objects and select HSpawnPoint 1 to HSpawnPoint 4 instead of the currently selected game objects.
And that’s it – don’t forget to save the scene.
Click on Play to start the game. The enemies will now spawn randomly at the spawn points, hunt the player and attack him.
This concludes the survival shooter game tutorial series for now. You can add additional content to the game, e.g. new levels and enemies or power ups (e.g. increasing the player’s damage or decreasing the fire timeout).