Setting up the machines generating the level.
In this tutorial we’ll add the schematics we created in the previous tutorial using an Auto Machine and 3 Tagged Machine components.
First, create a new empty game object (e.g. using the Unity menu: Game Object > Create Empty), rename it to GameManager and place it at X=-2, Y=0, Z=0. We’ll be adding the machine components to this game object.
Board Manager: Auto Machine
The BoardManager schematic handles generating the level – we’ll use an auto machine to do this at the start of the level.
Add an auto machine component to the GameManager (e.g. using the component menu: Makinom > Machines > Auto Machine) and change the following settings.
Start Settings
- Start
Enable this setting.
Machine Execution Settings
- Asset Type
Select Schematic. - Schematic Asset
Select BoardManager. - Execution Type
Select Single. - Update Type
Select Update. - Stop On Destroy
Disable this setting.
Local Start Variables
The Machine Start Variables we’ve set up in the schematic are automatically added here with their default values – since the default values are already what we need, we don’t have more to do here. Make sure all variables are enabled.
That’s it for the auto machine.
Random Placement: Tagged Machines
We’ll add 3 tagged machines for the random placement.
Walls
Add a tagged machine component to the GameManager (e.g. using the component menu: Makinom > Machines > Tagged Machine) and change the following settings.
Start Settings
Click on Add Starting Tag to add a tag that can start this machine.
- Starting Tag
Set to walls.
Machine Execution Settings
- Asset Type
Select Schematic. - Schematic Asset
Select RandomPlacement. - Execution Type
Select Single. - Update Type
Select Update.
Resource Overrides
Expand the Resource Overrides to change the used prefabs.
- Override Prefabs
Enable this setting.
Click on Add Prefab multiple times – we’ll need 8 prefabs in total.
- Prefab
Select Wall1 to Wall8.
The prefabs can be found at Assets/Tutorial Resources/Prefabs/.
Local Start Variables
- Set Start Variables
Enable this setting.
Click on Add Variable to add a start variable.
- Variable Key
Set to objectCount.
Use the Value string type. - Type
Select Int. - Operator
Select Set. - Float Value
Select Random. - Value
Set to 5. - Value 2
Set to 9.
We’ll be adding between 5 and 9 walls to the level.
Food
Copy the previous tagged machine by right clicking on the component’s name and selecting Copy Component. Add it by right clicking on the name again and selecting Paste Component As New.
Change the following settings.
Start Settings
- Starting Tag
Set to food.
Resource Overrides
Expand the Resource Overrides to change the used prefabs.
We only need 2 prefabs this time, i.e. remove the not needed amount.
- Prefab
Select Food and Soda.
The prefabs can be found at Assets/Tutorial Resources/Prefabs/.
Local Start Variables
Change the random numbers – we’ll be adding between 1 and 5 food items to the level.
- Value
Set to 1. - Value 2
Set to 5.
Enemies
Again, copy the previous tagged machine by right clicking on the component’s name and selecting Copy Component. Add it by right clicking on the name again and selecting Paste Component As New.
Change the following settings.
Start Settings
- Starting Tag
Set to enemies.
Resource Overrides
Expand the Resource Overrides to change the used prefabs.
- Prefab
Select Enemy1 and Enemy2.
The prefabs can be found at Assets/Tutorial Resources/Prefabs/.
Local Start Variables
The enemy objectCount will be set by the BoardManager that calls this tagged machine, so we don’t need local start variables this time.
- Set Start Variables
Disable this setting.
And that’s it for now – don’t forget to save the scene.
Testing
Click on Play to test the game. A text will be displayed (Day 1), after the screen faded in, you’ll see the generated level – each time you start the game, different level will be generated.
The next tutorial will handle the player controls.