Setting up the pickup spawner.
In this tutorial we’ll create the schematic spawning pickups and set up the global machine playing the schematic.
First, we’ll set up the schematic spawning the pickups.
Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.
We’ll add the bomb crate and health crate as prefabs.
Click on Add Prefab Resource to add a prefab resource.
Click on Add Prefab Resource to add another prefab resource.
Add Node > Base > Wait
We’ll wait 5 seconds between pickup spawns.
Add Node > Value > Variable > Change Variables
We’ll use this node to create a spawn position with a random X-axis.
Click on Add Variable to add a variable change.
Add Node > Value > Variable > Variable Fork
We’ll use this node to check the player’s health – this will determine which pickup can be spawned.
If the player’s health is above 75, we’ll spawn a bomb. If the player’s health is below 25, we’ll spawn a health crate. In any other case, we’ll randomly spawn a bomb or health crate.
Change the already added variable condition.
Copy the variable condition.
Add Node > Base > Random
This node is used to randomly play a next node. We’ll use it to randomly spawn a bomb or health crate in the next step.
This node is connected to the Failed slot of the Variable Fork node.
Click on Add Node to add a 2nd random slot – the node should now have 2 slots.
Add Node > Game Object > Prefab > Spawn Prefab
We’ll use this node to spawn a bomb crate.
This node is connected to slot 0 of the Variable Fork node (health is greather equal 75) and the Random 0 slot of the Random node.
We’ll use this node to spawn a health crate, copy the previous node and change the following settings.
This node is connected to slot 1 of the Variable Fork node (health is less equal 25) and the Random 1 slot of the Random node.
That’s it for the schematic – click on Save Schematic and save it as PickupSpawner in Assets/Schematics/.
Now we’ll set up the global machine handling our pickup spawning. You can learn more about them in the global machines documentation.
Navigate to Base/Control > Global Machines and change the settings of the first global machine (Default). We’ve already used that global machine in our health pickup and bomb schematics.
The pickup spawner should automatically start when the level was loaded to spawn the first pickup.
That’s it for the global machine – click on Save Settings to save the changes.
We need to do one more thing – because the global machine will only start when loading a level, it wont start when we play the scene in the editor (because that wont load the level, only after the player died this mechanic kicks in, as we reload it in that case). We’ll use the PickupSpawner schematic as a start schematic in the Game Starter.
Select the Game Starter game object in the scene hierarchy and change the following settings in the inspector.
And that’s it – don’t forget to save the scene.
Click on Play to start the game. Pickups will now be spawned after 5 seconds in the game. After a bomb exploded or a health crate was collected, the next pickup will be spawned after another 5 seconds.
The next tutorial will handle the UI setup.
© 2015 Gaming is Love e.U.
Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!