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
  • Survival Shooter
  • 05 Setting up the Enemies

05 Setting up the Enemies

Table of Contents
  • Object Variables
  • Enemy Movement: Tick Machine
    • Start Settings
    • Machine Execution Settings
  • Enemy Attack: Trigger Machine
    • Start Settings
    • Machine Execution Settings
    • Condition Settings
    • Local Start Variables
  • Take Damage: Tagged Machine
    • Start Settings
    • Machine Execution Settings
    • Resource Overrides
  • Enemy Death: Tagged Machine
    • Start Settings
    • Machine Execution Settings
    • Resource Overrides
  • Testing

Setting up the enemy machines.

In this tutorial we’ll set up the enemy game objects. We’ll add the schematics we created in the previous tutorial using different machines.

The setup for all 3 enemies (Zombunny, ZomBear and Hellephant) is the same (except for minimal differences). The following component setup can be repeated for all enemy prefabs, or you can just copy the components and paste them on the other enemies.

The enemy prefabs can be found at Assets/Tutorial Resources/Prefabs/. We’ll add the components directly to the prefabs.

Object Variables #

First, we’ll set up the object variables of the enemies. 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 enemies can be spawned multiple times, so we don’t want them to share their variables.
  • Always Initialize
    Enable this setting.

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
    Zombunny: Set to 100 (Value).
    ZomBear: Set to 100 (Value).
    Hellephant: Set to 300 (Value).

Copy the variable and change the following settings.

  • Variable Key
    Set to points.
  • Float Value
    Zombunny: Set to 10 (Value).
    ZomBear: Set to 10 (Value).
    Hellephant: Set to 50 (Value).

That’s it for the object variables.

Enemy Movement: Tick Machine #

Next, we’ll add the EnemyMovement schematic using a tick machine.

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

Start Settings #

  • Update
    Enable this setting.

Machine Execution Settings #

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

Enemy Attack: Trigger Machine #

The enemy’s attack will be started while the player is within the enemy’s trigger.

Add a trigger machine component to the enemy prefabs (e.g. using the component menu: Makinom > Machines > Trigger Machine). Change the following settings.

Start Settings #

  • Trigger Stay
    Enable this setting.

Machine Execution Settings #

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

Condition Settings #

The attack should only start if the enemy’s and player’s health is above 0 using our template.

Click on Add Condition, we’ll set up the variable conditions here.

  • Auto Check
    Select None.

In the added Condition 0, we’ll set up our variable condition.

  • Condition Type
    Select Variable.
  • Needed
    Select All.

Click on Add Variable.

  • Condition Type
    Select Template.
  • Template
    Select Is Alive.
  • Game Object (User Object)
    Select User.
    This’ll check the machine’s game object, i.e. the enemy.

Copy the added variable condition and change the following settings.

  • Game Object (User Object)
    Select Player.

Local Start Variables #

The Machine Start Variables we’ve set up in the schematic are automatically added here with their default values, so all we need to do is adjust them to our needs. Make sure both variables are enabled.

  • damage
    Zombunny: Set to 10.
    ZomBear: Set to 15.
    Hellephant: Set to 30.
  • attackTimeout
    We can keep the default value of 0.5 on all enemy prefabs.

Take Damage: Tagged Machine #

Now, we’ll add the TakeDamage schematic using a tagged machine that will be stared by the tag damage.

Add a tagged machine component to the enemy 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 damage.

Machine Execution Settings #

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

Resource Overrides #

Expand the Resource Overrides to change the used audio clip.

  • Override Audio Clips
    Enable this setting.

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

  • Audio Clip
    Zombunny: Select ZomBunny Hurt.
    ZomBear: Select ZomBear Hurt.
    Hellephant: Select Hellephant Hurt.
    The audio clips can be found at Assets/Tutorial Resources/Audio/Effects/.

Enemy Death: Tagged Machine #

Finally, we’ll add the EnemyDeath schematic using a tagged machine started by the tag death.

Add a tagged machine component to the enemy 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 death.

Machine Execution Settings #

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

Resource Overrides #

Expand the Resource Overrides to change the used audio clip.

  • Override Audio Clips
    Enable this setting.

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

  • Audio Clip
    Zombunny: Select ZomBunny Death.
    ZomBear: Select ZomBear Death.
    Hellephant: Select Hellephant Death.
    The audio clips can be found at Assets/Tutorial Resources/Audio/Effects/.

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

Testing #

If you want to test your enemies, just drag them into the scene and click on Play. The enemis will move toward the player, if you shoot them, they’ll die once their health is gone. They aren’t yet able to damage the player, since we didn’t add the TakeDamage schematic to the player yet – we’ll do this later.

The next tutorial will handle UI setup.

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on January 5, 2021
Table of Contents
  • Object Variables
  • Enemy Movement: Tick Machine
    • Start Settings
    • Machine Execution Settings
  • Enemy Attack: Trigger Machine
    • Start Settings
    • Machine Execution Settings
    • Condition Settings
    • Local Start Variables
  • Take Damage: Tagged Machine
    • Start Settings
    • Machine Execution Settings
    • Resource Overrides
  • Enemy Death: Tagged Machine
    • Start Settings
    • Machine Execution Settings
    • Resource Overrides
  • 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!