Setting up the player’s death schematic and game over.
In this tutorial we’ll create the schematic handling the player’s death and game over, and add tagged machines for receiving damage and death to the player.
First, we’ll set up the schematic animating the player’s death and displaying a game over dialogue. When the player selects restart, the level will be reloaded, starting a new game.
Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.
Add Node > Animation > Mecanim > Play Mecanim Animation
We’ll use this node to play the death animation of the player by setting the Die trigger parameter.
Click on Add Parameter to add an parameter that will be changed.
Add Node > Audio > Audio > Play Sound
We’ll use this node to play the player’s death sound.
Add Node > Base > Wait
We’ll wait for 1 second.
Add Node > UI > Dialogue > Show Dialogue
This node will display a dialogue using a GUI box. We’ll display the game over message as a choice dialogue.
Click on Add Choice to add a choice. We’ll display a single choice for the player to restart the game.
Add Node > Game > Scene > Load Scene
This node will load a scene. We’ll use it to reload the current scene.
This node is connected to the Choice 0 slot of the Show Dialogue node.
Add Node > Value > Variable > Change Variables
We’ll reset the score to 0. Click on Add Variable to add a variable change.
And that’s it for the schematic – click on Save Schematic and save it as PlayerDeath in Assets/Schematics/.
Now, we’ll first add the tagged machine handling the player taking damage. Select the Player game object in the scene and add a tagged machine component to it (e.g. using the component menu: Makinom > Machines > Tagged Machine). Change the following settings.
Click on Add Starting Tag to add a tag that can start this machine.
Expand the Resource Overrides to change the used audio clip.
Click on Add Audio Clip to add an audio clip that will be used.
Finally, we’ll add the PlayerDeath schematic using a tagged machine. Add a tagged machine component to the Player game object (e.g. using the component menu: Makinom > Machines > Tagged Machine). Change the following settings.
And that’s it for now – apply the changes to the prefab by clicking on Overrides > Apply All (top of the inspector).
Don’t forget to save the scene.
Drag some of the enemy prefabs into the scene and click on Play. The enemis will now be able to damage the player – once the player’s health reaches 0, the player dies and the game over dialogue is displayed.
The next tutorial will handle spawning enemies.
© 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!