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
  • Space Shooter
  • 05 Asteroids

05 Asteroids

Table of Contents
  • Random Rotator: Schematic
    • Settings
      • Machine Start Variables
    • Vector3 Multiply
      • Variable Settings
      • Vector3 Value
      • Multiply By
    • Change Fields
      • Field Settings
      • Object
  • Setting up the Asteroids
    • Object Variables
    • Mover: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Random Rotator: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Destroy: Tagged Machine
      • Start Settings
      • Machine Execution Settings
    • Hit: Trigger Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables

Setting up the asteroids.

The game will have 3 different asteroids. We’ll need another schematic to randomly rotate the asteroids, the rest of the needed schematics is already set up.

Random Rotator: Schematic #

This schematic will randomly rotate the asteroid’s game object by setting the rigidbody’s angular velocity. Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.

Settings #

We’ll set up a local variable as Machine Start Variable for easy setup in the machine component at a later time. When using the schematic in a machine component, the defined start variables will be added automatically, using their default values.

Machine Start Variables #

Click on Add Start Variable to add a local start variable that will be exposed to the machine component’s inspector.

  • Variable Key
    Set to tumble.
  • Type
    Select Float.
  • Default Value
    Set to 5.

Vector3 Multiply #

Add Node > Value > Vector > Vector3 Multiply

We’ll store the velocity into a local Vector3 variable, using a randomly generated Vector3 value and the local float variable tumble (local start variable of the machine component).

Variable Settings #

  • Variable Key
    Set to velocity.
  • Variable Origin
    Select Local.
  • Operator
    Select Set.

Vector3 Value
#

  • Vector3 Type
    Select Random > Random Inside Sphere.
    This will create a random Vector3 value with X, Y and Z being randomly between 0 and 1.

Multiply By
#

  • Multiply By
    Select Variable > Float Variable.
  • Variable Key
    Select tumble.
  • Variable Origin
    Select Local.

Change Fields #

Add Node > Function > Change Fields

This node will change fields and properties of a component (or class) using reflection. Since there is no specific node to change the angular velocity of a rigidbody, we’ll use this node to set the value instead.

Field Settings #

  • Class Origin
    Select Component.
  • Class Name
    Set to Rigidbody.

Click on Add Field to add a field/property that will be changed on the defined component/class.

  • Field Name
    Set to angularVelocity.
  • Is Property
    Enable this setting.
    The rigidbody’s angular velocity is a property, not a field.
  • Field Type
    Select Vector3.
  • Vector3 Type
    Select Vector3 Variable.
  • Variable Key
    Set to velocity.
  • Variable Origin
    Select Local.

Object #

  • Object
    Select Machine Object.

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

Setting up the Asteroids #

The setup for all 3 asteroids is the same (except for minimal differences in the Object Variables). The following component setup can be repeated for all asteroid prefabs, or you can just copy the components and paste them on the other asteroids.

You can copy a component by right-clicking on the component’s name and selecting Copy Component in the context menu. To paste the component on a game object, right-click on any component’s name and select Paste Component As New in the context menu.

The asteroid prefabs (Asteroid 1, Asteroid 2 and Asteroid 3) can be found at Assets/Tutorial Resources/.

Object Variables #

First, we’ll set up the object variables of the asteroids. Add an object variable component to the prefabs (e.g. using the component menu: Makinom > Scenes > Object Variables). Change the following settings.

  • Local Variables
    Enable this setting.
    The asteroids can be spawned multiple times, so we don’t want them to share their variables.
  • Always Initialize
    Enable this setting.
    This makes sure that the variables will be initialized each time the game object is spawned/activated.

Click on Add Variable to add an object variable.

  • Variable Key
    Set to health.
    Select the Value string type.
  • Type
    Select Int.
  • Operator
    Select Set.
  • Float Value
    Asteroid 1: Set to 1 (Value).
    Asteroid 2: Set to 2 (Value).
    Asteroid 3: Set to 3 (Value).
    The asteroids will have different health values, i.e. asteroid 1 will need 1 hit to be destroyed, asteroid 3 will need 3 hits.

Copy the variable and change the following settings.

  • Variable Key
    Set to points.
  • Float Value
    Asteroid 1: Set to 50 (Value).
    Asteroid 2: Set to 75 (Value).
    Asteroid 3: Set to 100 (Value).
    The asteroids will add different points to the score.

That’s it for the object variables.

Mover: Auto Machine #

Next, we’ll add the Mover schematic using an auto machine component. The schematic will move a game object by setting the rigidbody’s velocity.

Add the component to the asteroid prefabs (e.g. using the component menu: Makinom > Machines > Auto Machine). Change the following settings.

Start Settings #

  • Enable
    Enable this setting.

Machine Execution Settings #

  • Schematic Asset
    Select Mover.
  • Execution Type
    Select Single.
  • Update Type
    Select Fixed Update.

Local Start Variables #

The Machine Start Variable we’ve set up in the schematic is automatically added here, so all we need to do is adjust it to our needs. Make sure the variable is enabled.

  • speed
    Set to -5.

Random Rotator: Auto Machine #

Now, we’ll add the RandomRotator schematic using an auto machine component. The schematic will randomly rotate a game object by setting the rigidbody’s angular velocity.

Add the component to the asteroid prefabs (e.g. using the component menu: Makinom > Machines > Auto Machine). Change the following settings.

Start Settings #

  • Enable
    Enable this setting.

Machine Execution Settings #

  • Schematic Asset
    Select RandomRotator.
  • Execution Type
    Select Single.
  • Update Type
    Select Fixed Update.

Local Start Variables #

The Machine Start Variable we’ve set up in the schematic is automatically added here, the default value is all we need. Make sure the variable is enabled.

Destroy: Tagged Machine #

The Destroy schematic handles the destruction of a game object, spawning a particle effect prefab and playing and audio clip. The tagged machine component we’ll use for that will be started by the Hit schematic using the tag destroy.

Add the component to the asteroid prefabs (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 destroy.

Machine Execution Settings #

  • Schematics Asset
    Select Destroy.
  • Execution Type
    Select Single.
  • Update Type
    Select Update.
  • Stop On Destroy
    Disable this setting.
    This will allow the machine to continue when the game object was destroyed or disabled.

We don’t need to use resource overrides, since we used the asteroid’s particle effect and audio clip in the schematic.

Hit: Trigger Machine #

The Hit schematic reduces the health of game objects that are hit by the asteroids. If the health drops to 0, it will start the destroy tagged machine.

The hit mechanic will use a trigger, add a trigger component to the asteroid prefabs (e.g. using the component menu: Makinom > Machines > Trigger Machine).

Start Settings #

  • Trigger Enter
    Enable this setting.

Unlike the Bolt setup, we don’t need to use Start By Other or Limit Layers, because the asteroids will only need to hit the player’s game object.

Machine Execution Settings #

  • Schematics Asset
    Select Hit.
  • Execution Type
    Select Single.
  • Update Type
    Select Update.

Local Start Variables #

The Machine Start Variable we’ve set up in the schematic is automatically added here, the default value is all we need. Make sure the variable is enabled.

And that’s it for now. Since we’ve added the components to the prefabs directly, we don’t need to apply the changes.

The next tutorial will handle the game controller, which will spawn the enemy waves (only asteroids for now).

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on December 17, 2020
Table of Contents
  • Random Rotator: Schematic
    • Settings
      • Machine Start Variables
    • Vector3 Multiply
      • Variable Settings
      • Vector3 Value
      • Multiply By
    • Change Fields
      • Field Settings
      • Object
  • Setting up the Asteroids
    • Object Variables
    • Mover: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Random Rotator: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Destroy: Tagged Machine
      • Start Settings
      • Machine Execution Settings
    • Hit: Trigger Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
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!