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
  • 10 Enemy Ship

10 Enemy Ship

Table of Contents
  • Setting up the Enemy Bolt
    • Mover: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Hit: Trigger Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
  • Setting up the Enemy Ship
    • Object Variables
    • Enemy Mover: Tick Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Enemy Maneuver: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Destroy: Tagged Machine
      • Start Settings
      • Machine Execution Settings
      • Resource Overrides
    • Hit: Trigger Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Fire Shot: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Resource Overrides
  • Adjusting the Game Controller
    • Settings
      • Prefabs
  • Testing

Setting up the enemy ship’s machines.

After creating the schematics for moving the enemy ship, it’s time to set up the machine components on the prefab. However, first we’ll add the machine components to the enemy’s weapon bolt.

Setting up the Enemy Bolt #

Select the Bolt Enemy prefab (found at Assets/Tutorial Resources/Prefabs/). We’ll add a Mover schematic and a Hit schematic like we did with the player’s bolt.

Mover: Auto Machine #

The Mover schematic will be added using an auto machine component. The schematic will set the game object’s velocity when it’s added to the scene.

Add an auto machine component to the Bolt Enemy prefab (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 20.

Hit: Trigger Machine #

We’ll add the Hit schematic using a trigger machine component. Add a trigger machine component (e.g. using the component menu: Makinom > Machines > Trigger Machine).

Change the following settings.

Start Settings #

  • Trigger Enter
    Enable this setting.

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.

That’s it for the Enemy Bolt prefab. Since we added the component directly on the prefab, we don’t need to apply the changes.

Setting up the Enemy Ship #

Select the Enemy Ship prefab (found at Assets/Tutorial Resources/Prefabs/), we’ll add multiple components to it.

Object Variables #

First, we’ll set up the object variables of the enemy ship. 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 enemy ships 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
    Set to 1 (Value).

Copy the variable and change the following settings.

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

Click on Add Variable to add an object variable.

  • Variable Key
    Set to fireRate.
    Select the Value string type.
  • Type
    Select Float.
  • Operator
    Select Set.
  • Float Value
    Set to 1.5 (Value).

That’s it for the object variables.

Enemy Mover: Tick Machine #

The enemy ship is moved using a rigidbody component, i.e. we’ll need to Fixed Update for the physics updates.

Add a tick machine component to the prefab (e.g. using the component menu: Makinom > Machines > Tick Machine). Change the following settings.

Start Settings #

  • Fixed Update
    Enable this setting.
    The machine will be started in the fixed framerate frame.

Machine Execution Settings #

  • Schematic Asset
    Select EnemyMover.
  • Execution Type
    Select Single.
    The machine can only be executed once at a time.
  • Update Type
    Select Fixed Update.

Local Start Variables #

The Machine Start Variables we’ve set up in the schematic are automatically added here with their default values – since the default values are already what we need, we don’t have more to do here. Make sure all variables are enabled.

Enemy Maneuver: Auto Machine #

We’ll add the enemy maneuver schematic using a repeating auto machine component. This will restart the machine after it finished executing.

Add an auto machine component to the prefab (e.g. using the component menu: Makinom > Machines > Auto Machine) and change the following settings.

Start Settings #

  • Enable
    Enable this setting.
  • Repeat Execution
    Enable this setting.
    The machine will retry executing after it ended.

Machine Execution Settings #

  • Schematic Asset
    Select EnemyManeuver.
  • 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.

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

Resource Overrides #

First, we’ll override Prefab 0 used by the schematic.

  • Override Prefabs
    Enable this setting.

Click on Add Prefab to add a prefab that will be used.

  • Prefab
    Select explosion_enemy.

Now, we’ll override Audio Clip 0 used by the schematic.

  • Override Audio Clips
    Enable this setting.

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

  • Audio Clip
    Select explosion_enemy.

Hit: Trigger Machine #

The Hit schematic reduces the health of game objects that are hit by the enemy ship. 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.

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.

Fire Shot: Auto Machine #

Finally, we’ll add the FireShot schematic using a repeating auto machine. This will fire the enemy’s bolts according to the enemy’s fire rate.

Add an auto machine component to the prefab (e.g. using the component menu: Makinom > Machines > Auto Machine) and change the following settings.

Start Settings #

  • Enable
    Enable this setting.
  • Start Delay (s)
    Set to 0.5.
    The enemy ship will start firing after 0.5 seconds.
  • Repeat Execution
    Enable this setting.
    The machine will retry executing after it ended.

Machine Execution Settings #

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

Resource Overrides #

Expand the Resource Overrides to change the used prefab and audio clip.

First, we’ll override Prefab 0 used by the schematic.

  • Override Prefabs
    Enable this setting.

Click on Add Prefab to add a prefab that will be used.

  • Prefab
    Select Bolt Enemy.

Now, we’ll override Audio Clip 0 used by the schematic.

  • Override Audio Clips
    Enable this setting.

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

  • Audio Clip
    Select weapon_enemy.

That’s it for the Enemy Ship prefab. Since we added the component directly on the prefab, we don’t need to apply the changes.

Adjusting the Game Controller #

To get the enemy ship into the game, we’ll need to add it to the GameController schematic. Open the schematic, either through the Makinom editor, by double clicking on the asset file in the project view (can be found at Assets/Schematics/) or through the Edit Schematic button in the asset file’s inspector.

Settings #

Select the Settings node of the schematic and change the following settings.

Prefabs #

Click on Add Prefab in the Hazards prefab (Prefab 0).

  • Prefab
    Select Enemy Ship.
    Can be found at Assets/Tutorial Resources/Prefabs/.
  • Use Pooling
    Enable this setting.

And that’s it – click on Save Schematic to save the changes.

Testing #

Click on Play to test the game. The enemy waves will now also contain enemy ships. The enemy will fly evasive maneuvers randomly and fire bolts at the player.

The final tutorial will be short and simple – moving the background.

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on December 17, 2020
Table of Contents
  • Setting up the Enemy Bolt
    • Mover: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Hit: Trigger Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
  • Setting up the Enemy Ship
    • Object Variables
    • Enemy Mover: Tick Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Enemy Maneuver: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Destroy: Tagged Machine
      • Start Settings
      • Machine Execution Settings
      • Resource Overrides
    • Hit: Trigger Machine
      • Start Settings
      • Machine Execution Settings
      • Local Start Variables
    • Fire Shot: Auto Machine
      • Start Settings
      • Machine Execution Settings
      • Resource Overrides
  • Adjusting the Game Controller
    • Settings
      • Prefabs
  • 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!