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 Platformer
  • 09 Health Pickup

09 Health Pickup

Table of Contents
  • Land Crate: Schematic
    • Check Object Name
    • Check Variables
    • Play Mecanim Animation
    • Mount Object
    • Add Component
    • Change Variables
  • Health Pickup: Schematic
    • Is Payer
      • Check Object
    • Start Tagged Machine
      • Machine Object
      • Starting Object
      • Tag Settings
    • Play Sound At Point
      • Position
      • Audio Settings
    • Change Variables
    • Check Variables
    • Change Variables
    • Start Global Machine
      • Machine Object
      • Starting Object
    • Destroy Object
      • Destroy Object
  • Health Crate Prefab
    • Object Variables
    • Health Pickup: Trigger Machine
      • Start Settings
      • Machine Execution Settings
    • Land Crate: Tagged Machine
      • Start Settings
      • Machine Execution Settings
  • Testing

Setting up the health pickup.

In this tutorial we’ll create the schematics to pick up health crates and pickups landing on the ground, and set up the the health crate prefab.

Land Crate: Schematic #

The pickups will be dropped from the sky, landing on parachutes. When they land, the need to be detached from the parachute – we’ll first create the schematic handling this mechanic. The schematic will be played by a trigger machine.

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

Check Object Name #

Add Node > Game Object > Game Object > Check Object Name

We’ll use this node to check if the game object that started the trigger machine has the tag ground.

  • Check Tag
    Enable this setting.
  • Check Value
    Set to ground.
  • Check Type
    Select Is Equal.
  • Object
    Select Starting Object.

Check Variables #

Add Node > Value > Variable > Check Variables

We’ll use this node to check if the crate has already landed. This will be stored in the object bool variable landed.

Click on Add Variable to add a variable condition.

  • Condition Type
    Select Variable.
  • Variable Key
    Set to landed.
  • Variable Origin
    Select Object.
  • Object
    Select Machine Object.
  • Is Valid
    Enable this setting.
  • Exists
    Enable this setting.
  • Type
    Select Bool.

Play Mecanim Animation #

Add Node > Animation > Mecanim > Play Mecanim Animation

We’ll use this node to play the landing animation on the root of the crate (i.e. the parachute – the crate object with the trigger machine is a child of it).

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

  • Object
    Select Machine Object.
  • Use Root
    Enable this setting.
  • Play Mode
    Select None.

Click on Add Parameter to add a parameter change.

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

Mount Object #

Add Node > Game Object > Game Object > Mount Object

We’ll use this node to unmount the crate from the parachute.

  • Mount
    Disable this setting.
  • Object
    Select Machine Object.

Add Component #

Add Node > Game Object > Component > Add Component

We’ll use this node to add a Rigidbody2D component to the crate.

  • Component Name
    Set to Rigidbody2D.
  • Object
    Select Machine Object.

Change Variables #

Add Node > Value > Variable > Change Variables

We’ll use this node to mark the crate as landed.

Click on Add Variable to add a variable change.

  • Change Type
    Select Variable.
  • Variable Key
    Set to landed.
  • Variable Origin
    Select Object.
  • Object
    Select Machine Object.
  • Type
    Select Bool.
  • Bool Value
    Enable this setting.

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

Health Pickup: Schematic #

Next, we’ll create the schematic handling the health pickup. Collecting the health crate will restore some health on the player, defined by an object variable on the crate.

Create a new schematic and change the following settings.

Is Payer #

Add Node > Game > Player > Is Player

First, we’ll check if the starting object is the player.

Check Object #

  • Object
    Select Starting Object.

Start Tagged Machine #

Add Node > Machine > Start Tagged Machine

In case the starting object is not the player, we’ll try to land the crate through a tagged machine.

This node is connected to the Failed slot of the Is Player node.

  • Share Local Variables
    Disable this setting.
  • Wait
    Enable this setting.

Machine Object #

  • Object
    Select Machine Object.

Starting Object #

  • Object
    Select Starting Object.

Tag Settings #

Click on Add Tag to add a starting tag.

  • Tag
    Set to land.

Play Sound At Point #

Add Node > Audio > Audio > Play Sound At Point

In case the starting object is the player, we’ll play a health pickup sound.

This node is connected to the Success slot of the Is Player node.

Position #

  • Vector3 Type
    Select Game Object > Game Object.
  • Object
    Select Machine Object.
  • Value Origin
    Select Position.

Audio Settings #

  • Audio Clip
    Select Select Audio Clip and healthPickup.
    The audio clip can be found at Assets/Tutorial Resources/Audio/FX/.
  • Wait
    Disable this setting.
  • Volume
    Set to 1 (Value).

Change Variables #

Add Node > Value > Variable > Change Variables

We’ll use this node to increase the player’s health by the crate’s health bonus.

Click on Add Variable to add a variable change.

  • Change Type
    Select Variable.
  • Variable Key
    Set to health.
  • Variable Origin
    Select Object.
  • Object
    Select Starting Object.
  • Type
    Select Int.
  • Operator
    Select Add.
  • Float Type
    Select Variable > Int Variable.
  • Variable Key
    Set to healthBonus.
  • Variable Origin
    Select Object.
  • Object
    Select Machine Object.

Check Variables #

Add Node > Value > Variable > Check Variables

Now we’ll check if the health exceeds the maximum health (i.e. 100).

Click on Add Variable to add a variable condition.

  • Condition Type
    Select Variable.
  • Variable Key
    Set to health.
  • Variable Origin
    Select Object.
  • Object
    Select Starting Object.
  • Is Valid
    Enable this setting.
  • Exists
    Enable this setting.
  • Type
    Select Int.
  • Check Type
    Select Is Greater.
  • Check Value
    Set to 100 (Value).

Change Variables #

Add Node > Value > Variable > Change Variables

In case the health exceeds maximum, we’ll need to set it to the maximum (100).

This node is connected to the Success slot of the previous Check Variables node (i.e. health is greater than 100).

Click on Add Variable to add a variable change.

  • Change Type
    Select Variable.
  • Variable Key
    Set to health.
  • Variable Origin
    Select Object.
  • Object
    Select Starting Object.
  • Type
    Select Int.
  • Operator
    Select Set.
  • Float Value
    Set to 100 (Value).

Start Global Machine #

Add Node > Machine > Start Global Machine

This node is used to start a global machine. We’ll use it to start the global machine handling the pickup spawning – we’ll set it up later, so just select the first global machine that we’ll use later. Picking up a health crate will result in the next pickup being spawned after some time.

This node is connected to the previous node’s Next slot and the Failed slot of the previous Check Variables node (i.e. health is less than 100).

  • Global Machine
    Select 0: Default.
  • Wait
    Disable this setting.

Machine Object #

  • Object
    Select Player.

Starting Object #

  • Object
    Select Player.

Destroy Object #

Add Node > Game Object > Game Object > Destroy

Finally, we’ll destroy the crate’s game object.

Destroy Object #

  • Object
    Select Machine Object.
  • Use Root
    Enable this setting.
    We’ll need to destroy the game object from it’s root, in case the crate is still hanging on the parachute.

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

Health Crate Prefab #

Now we’ll set up the healthCrate prefab – we need to add object variables, a trigger machine (HealthPickup schematic) and a tagged machine (LandCrate schematic). The healthCrate prefab can be found at Assets/Tutorial Resources/Prefabs/Pickups/.

We’ll add the components to the health child object of the healthCrate prefab.

Object Variables #

First, we’ll add the object variables. Add an object variable component to the prefab (e.g. using the component menu: Makinom > Scenes > Object Variables) and change the following settings.

  • Local Variables
    Enable this setting.
  • Always Initialize
    Enable this setting.

Click on Add Variable to add an object variable. This variable will store the amount of health that will be restored if the pickup is collected.

  • Variable Key
    Set to healthBonus.
    Select the Value string type.
  • Type
    Select Int.
  • Operator
    Select Set.
  • Float Value
    Set to 25 (Value).

Health Pickup: Trigger Machine #

Next, we’ll add a trigger machine that will handle the pickup by the player (or landing the crate if it’s not the player). Add a trigger machine component to the prefab (e.g. using the component menu: Makinom > Machines > Trigger Machine) and change the following settings.

Start Settings #

  • Trigger Enter
    Enable this setting.
  • Start By Other (Starting Objects)
    Enable this setting.

Machine Execution Settings #

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

Land Crate: Tagged Machine #

Finally, we’ll add a tagged machine that will handle landing the crate. Add a tagged machine component to the prefab (e.g. using the component menu: Makinom > Machines > Tagged Machine) and change the following settings.

Start Settings #

Click on Add Tag to add a starting tag

  • Tag
    Set to land.

Machine Execution Settings #

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

And that’s it – we don’t need to apply the changes, since we’ve worked on the prefab directly.

Testing #

If you want to test your health crate, just drag it into the scene and click on Play. The health crate will float down and land on the ground – the player can pick it up on the ground or in the air.

The next tutorial will handle the bomb pickup.

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on January 7, 2021
Table of Contents
  • Land Crate: Schematic
    • Check Object Name
    • Check Variables
    • Play Mecanim Animation
    • Mount Object
    • Add Component
    • Change Variables
  • Health Pickup: Schematic
    • Is Payer
      • Check Object
    • Start Tagged Machine
      • Machine Object
      • Starting Object
      • Tag Settings
    • Play Sound At Point
      • Position
      • Audio Settings
    • Change Variables
    • Check Variables
    • Change Variables
    • Start Global Machine
      • Machine Object
      • Starting Object
    • Destroy Object
      • Destroy Object
  • Health Crate Prefab
    • Object Variables
    • Health Pickup: Trigger Machine
      • Start Settings
      • Machine Execution Settings
    • Land Crate: 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!