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
  • 12 Pickup Spawner

12 Pickup Spawner

Table of Contents
  • Pickup Spawner: Schematic
    • Settings
      • Prefabs
    • Wait
    • Change Variables
    • Variable Fork
      • Variable Settings
    • Random
    • Spawn Prefab
      • Position
    • Spawn Prefab
  • Pickup Spawner: Global Machine
    • Machine Execution Settings
    • Execution Settings
  • Updating the Game Starter
  • Testing

Setting up the pickup spawner.

In this tutorial we’ll create the schematic spawning pickups and set up the global machine playing the schematic.

Pickup Spawner: 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.

Settings #

We’ll add the bomb crate and health crate as prefabs.

Prefabs #

Click on Add Prefab Resource to add a prefab resource.

  • Name
    Set to Health.
  • Prefab
    Select healthCrate.
    The prefab can be found at Assets/Tutorial Resources/Prefabs/Pickup/.

Click on Add Prefab Resource to add another prefab resource.

  • Name
    Set to Bomb.
  • Prefab
    Select bombCrate.
    The prefab can be found at Assets/Tutorial Resources/Prefabs/Pickup/.

Wait #

Add Node > Base > Wait

We’ll wait 5 seconds between pickup spawns.

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

Change Variables #

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.

  • Change Type
    Select Variable.
  • Variable Key
    Set to position.
  • Variable Origin
    Select Local.
  • Type
    Select Vector3.
  • Operator
    Select Set.
  • Vector3 Type
    Select Value > Set Axis.
  • X-Axis
    Select Value > Random and set the 1st field to -15 and the 2nd field to 15.
  • Y-Axis
    Set to 15 (Value).
  • Z-Axis
    Set to 1 (Value).

Variable Fork #

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.

Variable Settings #

  • Variable Key
    Set to health.
  • Variable Origin
    Select Object.
  • Object
    Select Player.

Change the already added variable condition.

  • Is Valid
    Enable this setting.
  • Exists
    Enable this setting.
  • Type
    Select Int.
  • Check Type
    Select Is Greater Equal.
  • Check Value
    Set to 75 (Value).

Copy the variable condition.

  • Check Type
    Select Is Less Equal.
  • Check Value
    Set to 25 (Value).

Random #

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.

Spawn Prefab #

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.

  • Prefab
    Select Prefab 1: Bomb.
  • Target Type
    Select Position.

Position #

  • Vector3 Type
    Select Vector3 Variable.
  • Variable Key
    Set to position.
  • Variable Origin
    Select Local.

Spawn Prefab #

Add Node > Game Object > Prefab > Spawn Prefab

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.

  • Prefab
    Select Prefab 0: Health.

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

Pickup Spawner: Global Machine #

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.

Machine Execution Settings #

  • Name
    Set to Pickup Spawner.
  • Schematic Asset
    Select PickupSpawner.
  • Execution Type
    Select Single.
  • Update Type
    Select Update.

Execution Settings #

The pickup spawner should automatically start when the level was loaded to spawn the first pickup.

  • Global Machine Type
    Select Scene.

That’s it for the global machine – click on Save Settings to save the changes.

Updating the Game Starter #

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.

  • Start Schematic Asset
    Select PickupSpawner.

And that’s it – don’t forget to save the scene.

Testing #

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.

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on January 8, 2021
Table of Contents
  • Pickup Spawner: Schematic
    • Settings
      • Prefabs
    • Wait
    • Change Variables
    • Variable Fork
      • Variable Settings
    • Random
    • Spawn Prefab
      • Position
    • Spawn Prefab
  • Pickup Spawner: Global Machine
    • Machine Execution Settings
    • Execution Settings
  • Updating the Game Starter
  • 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!