Makinom - Game Toolkit for Unity
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom

Guide

Schematics

  • Setting the Player
  • Simple Character Controller
  • Mouse Orbit Camera
  • Random Waypoints

Breakout

  • Breakout Tutorial Introduction
  • 01 First Steps
  • 02 Player Controls
  • 03 Bricks
  • 04 Losing a Life
  • 05 UI Setup
  • 06 Sound Assignments

Space Shooter

  • Space Shooter Tutorial Introduction
  • 01 First Steps
  • 02 Player Move Controls
  • 03 Player Weapon Controls
  • 04 Hit and Destroy
  • 05 Asteroids
  • 06 Game Controller
  • 07 UI Setup
  • 08 Player’s Destruction
  • 09 Enemy Ship Mechanics
  • 10 Enemy Ship
  • 11 Moving the Background

Match 3

  • Match 3 Tutorial Introduction
  • 01 First Steps
  • 02 UI Setup
  • 03 Generating the Level
  • 04 Matching Jewels
  • 05 Destroying Jewels
  • 06 Game Controls
  • 07 Jewel Setup

Survival Shooter

  • Survival Shooter Tutorial Introduction
  • 01 First Steps
  • 02 Player Movement
  • 03 Player Shooting
  • 04 Enemy Mechanics
  • 05 Setting up the Enemies
  • 06 UI Setup
  • 07 Player’s Death
  • 08 Enemy Spawner

2D Roguelike

  • 2D Roguelike Tutorial Introduction
  • 01 First Steps
  • 02 Generating the Level
  • 03 Level Generation Machines
  • 04 Player Controls
  • 05 Walls, Food and Exit
  • 06 Game Manager and UI Setup
  • 07 Enemy Mechanics
  • 08 Game Over

2D Platformer

  • 2D Platformer Tutorial Introduction
  • 01 First Steps
  • 02 Player Movement
  • 03 Camera and Background
  • 04 Shooting Rockets
  • 05 Enemy Mechanics
  • 06 Setting up the Enemies
  • 07 Enemy Spawners
  • 08 Player Damage and Fall Remover
  • 09 Health Pickup
  • 10 Bomb Pickup
  • 11 Bomb Prefabs and Lay Bombs
  • 12 Pickup Spawner
  • 13 UI Setup
  • 14 Background Animations
  • Home
  • Guide
  • Tutorials
  • Survival Shooter
  • 07 Player’s Death

07 Player’s Death

Table of Contents
  • Player Death: Schematic
    • Play Mecanim Animation
    • Play Sound
      • Play On
      • Audio Settings
    • Wait
    • Show Dialogue
      • Choice Settings
    • Load Scene
    • Change Variables
  • Take Damage: Tagged Machine
    • Start Settings
    • Machine Execution Settings
    • Resource Overrides
  • Player Death: Tagged Machine
    • Start Settings
    • Machine Execution Settings
  • Testing

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.

Player Death: Schematic #

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.

Play Mecanim Animation #

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.

  • Object
    Select Machine Object.
  • Play Mode
    Select None.

Click on Add Parameter to add an parameter that will be changed.

  • Parameter Name
    Set to Die.
  • Parameter Type
    Select Trigger.

Play Sound #

Add Node > Audio > Audio > Play Sound

We’ll use this node to play the player’s death sound.

Play On #

  • Object
    Select Machine Object.

Audio Settings #

  • Audio Clip
    Select Select Audio Clip and Player Death.
    The audio clip can be found at Assets/Tutorial Resources/Audio/Effects/.
  • Play One Shot
    Enable this setting.
  • Volume
    Set to 1.

Wait #

Add Node > Base > Wait

We’ll wait for 1 second.

  • Time (s)
    Set to 1 (Value).

Show Dialogue #

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.

  • Dialogue Type
    Select Choice.
  • UI Box
    Select Message.
  • Text (Message Content)
    Set to:
    Game Over

Choice Settings #

Click on Add Choice to add a choice. We’ll display a single choice for the player to restart the game.

  • Text (Choice 0)
    Set to:
    Restart

Load Scene #

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.

  • Reload Scene
    Enable this setting.
  • Load Type
    Select Load Level.
  • Position Type
    Select None.
    Since we already have the player in our scene, we don’t need Makinom to spawn the game object.

Change Variables #

Add Node > Value > Variable > Change Variables

We’ll reset the score to 0. Click on Add Variable to add a variable change.

  • Change Type
    Select Variable.
  • Variable Key
    Set to score.
  • Variable Origin
    Select Global.
  • Type
    Select Int.
  • Operator
    Select Set.
  • Float Value
    Set to 0 (Value).

And that’s it for the schematic – click on Save Schematic and save it as PlayerDeath in Assets/Schematics/.

Take Damage: Tagged Machine #

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.

Start Settings #

Click on Add Starting Tag to add a tag that can start this machine.

  • Starting Tag
    Set to damage.

Machine Execution Settings #

  • Schematic Asset
    Select TakeDamage.
  • Execution Type
    Select Single.
  • Update Type
    Select Update.

Resource Overrides #

Expand the Resource Overrides to change the used audio clip.

  • Override Audio Clips
    Enable this setting.

Click on Add Audio Clip to add an audio clip that will be used.

  • Audio Clip
    Select Player Hurt.

Player Death: Tagged Machine #

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.

Start Settings #

Click on Add Starting Tag to add a tag that can start this machine.

  • Starting Tag
    Set to death.

Machine Execution Settings #

  • Schematic Asset
    Select PlayerDeath.
  • Execution Type
    Select Single.
  • Update Type
    Select Update.

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.

Testing #

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.

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on January 5, 2021
Table of Contents
  • Player Death: Schematic
    • Play Mecanim Animation
    • Play Sound
      • Play On
      • Audio Settings
    • Wait
    • Show Dialogue
      • Choice Settings
    • Load Scene
    • Change Variables
  • Take Damage: Tagged Machine
    • Start Settings
    • Machine Execution Settings
    • Resource Overrides
  • Player Death: Tagged Machine
    • Start Settings
    • Machine Execution Settings
  • Testing
Sitemap
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom
  • Contact
  • Blog
  • ORK Framework
  • gamingislove.com
Categories
  • Makinom 1 (97)
    • Tutorial (97)
      • 2D Platformer (14)
      • 2D Roguelike (8)
      • Breakout (6)
      • How-to (34)
      • Match 3 (6)
      • Schematic (4)
      • Scripting (6)
      • Space Shooter (11)
      • Survival Shooter (8)
  • News (11)
  • Release (68)
Search

© 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!