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
  • 2D Roguelike
  • 08 Game Over

08 Game Over

Table of Contents
  • Check Game Over: Schematic
    • Check Variables
    • Change Game State
    • Play Sound
      • Play On
      • Audio Settings
    • Fade Screen
    • Show Dialogue
    • Change Variables
    • Load Scene
  • Check Game Over: Tagged Machine
    • Start Settings
    • Machine Execution Settings
  • Testing

Setting up the game over mechanic.

In this tutorial we’ll create a schematic to check the player’s food and end the game if the food is gone. Game over will display a message and restart the game.

Check Game Over: Schematic #

First, we’ll create the schematic to check and handle game over.

Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.

Check Variables #

Add Node > Value > Variable > Check Variables

We’ll use this node to check if the player’s food is gone.

Click on Add Variable to add a variable condition.

  • Condition Type
    Select Variable.
  • Variable Key
    Set to food.
  • Variable Origin
    Select Global.
  • Is Valid
    Enable this setting.
  • Exists
    Enable this setting.
  • Type
    Select Int.
  • Check Type
    Select Is Less Equal.
  • Check Value
    Set to 0 (Value).

Change Game State #

Add Node > Game > Game > Change Game State

We’ll use this node to start stop the game from running.

This node is connected to the Success slot of the previous node.

Click on Add Game State to add a game state change.

  • Game State
    Select Game Running.
  • Set State
    Select Inactive.

Play Sound #

Add Node > Audio > Audio > Play Sound

We’ll use this node to play a death sound.

Play On #

  • Object
    Select Machine Object.

Audio Settings #

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

Fade Screen #

Add Node > UI > Fade Screen

Now it’s time to fade out the screen.

  • Wait
    Enable this setting.
  • Time (s)
    Set to 0.25.
  • Fade Alpha
    Enable this setting.
  • Start Color
    Select a black color without alpha (R=0, G=0, B=0, A=0).
  • End Color
    Select a black color with full alpha (R=0, G=0, B=0, A=255).

Show Dialogue #

Add Node > UI > Dialogue > Show Dialogue

This node is used to show a dialogue. We’ll use it to display the current day (level).

  • Dialogue Type
    Select Auto Close.
    The dialogue will close automatically after some time.
  • UI Box
    Select Message.
  • Block Accept Button
    Enable this setting.
  • Close After (s)
    Set to 3.
  • Wait
    Enable this setting.
  • Text (Message Content)
    Set to:
    After <var.int=level> days, you starved.

Change Variables #

Add Node > Value > Variable > Change Variables

We’ll use this node to reset the level to 1 and the food to 100.

Click on Add Variable to add a variable change.

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

Copy the previous variable and change the following settings.

  • Variable Key
    Set to food.
  • Float Value
    Set to 100 (Value).

Load Scene #

Add Node > Game > Scene > Load Scene

We’ll use this node to reload the current scene – which will start generating a new level.

  • Reload Scene
    Enable this setting.
  • Position Type
    Select None.

Since the screen is already faded out and we don’t want to fade in (handled by the level generator), we’ll use a custom screen fade setup.

  • Own Screen Fade
    Enable this setting.
  • Fade Out
    Disable this setting.
  • Fade In
    Disable this setting.

That’s it for the schematic – click on Save Schematic and save it as CheckGameOver in Assets/Schematics/.

Check Game Over: Tagged Machine #

Finally, we’ll add the game over mechanic to the Player game object in the scene using a tagged machine. The machine will be started by enemy attacks and consuming food per turn.

Add a tagged machine component to the player (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 checkGameOver.

Machine Execution Settings #

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

And that’s it – apply the changes to the player’s prefab by clicking on Overrides > Apply All (top of the inspector).

Don’t forget to save the scene.

Testing #

Click on Play to test the game. You’ll now be able to die when running out of food.

This concludes the 2D roguelike game tutorial series. You can add additional content to the game, e.g. bigger levels (setting columns and rows in the machine starting the BoardManager schematic) or power ups for the player to chop through walls faster (changing the global variable wallDamage).

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on January 6, 2021
Table of Contents
  • Check Game Over: Schematic
    • Check Variables
    • Change Game State
    • Play Sound
      • Play On
      • Audio Settings
    • Fade Screen
    • Show Dialogue
    • Change Variables
    • Load Scene
  • Check Game Over: 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 (67)
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!