DUNGEON 04 Traps on Level 3

In this tutorial we’ll set up traps and dungeon level 3.

This tutorial continues the sub-series for setting up the dungeon.

You might have noticed the strange floor plates with holes in some parts of the Dungeon Level 3 scene (open the scene if you haven’t already, found in Assets/Scenes/Dungeon/). We’ll turn them into traps.

Like we did with the trapdoor, we’ll make those changes directly on the prefab to have them on all traps in the dungeon.

There are 2 ways to create traps – one involves using Damage Dealer (in Always Active environmental damage setup) and Damage Zone components (learn more about those components in this documentation), the other simply using schematics.

Since we don’t use damage dealers/zones in our setup, we’ll just use schematics.

Spike Trap Schematic #

Our schematic will activate a child object of the trap’s game object (the spikes), damage the player group’s health by 10% and disable the spikes again (after a short wait).

The controls will not be blocked, so the trap just activates while the player can continue to move (i.e. we don’t need to set that up in the Settings node).

Activate Object #

Add Node > Game Object > Game Object > Activate Object

We’ll enable a child object of the trap (Machine Object), the Spikes.

  • Set Active
    Enable this setting.
  • Object
    Select Machine Object.
  • Child Object
    Set to Spikes.

Play Sound #

Add Node > Audio > Audio > Play Sound

We’ll play the Damage sound type on the player.

  • Object (Play On)
    Select Player.
  • Use Sound Type
    Enable this setting.
  • Sound Type
    Select Damage.
  • Play One Shot
    Enable this setting.

Change Status Value #

Add Node > Combatant > Status > Change Status Value

We’ll reduce the whole player group’s health by 10%.

  • Object (Combatant)
    Select Player.
  • Whole Group
    Enable this setting.
  • Status Value
    Select Health Points.
  • Show Flying Text
    Enable this setting.
  • Set In
    Select Percent.
  • Operator
    Select Sub.
  • Value
    Select Value > Value.
    Set the value to 10.

Wait #

Add Node > Base > Wait

We’ll wait for a second before disabling the spikes again.

  • Time
    Select Value > Value.
    Set the value to 1.

Activate Object #

Add Node > Game Object > Game Object > Activate Object

Copy the first Activate Object node and change the following setting.

  • Set Active
    Disable this setting.

And that’s it for the schematic. Click on Save Schematic to save it, e.g. as SpikeTrap.

The Spike Trap Prefab #

Select one of the traps (Trap_Block game object) in the scene.

Now, open the trap’s prefab to edit it.

We’ll add a Box Collider (used as trigger) and a Trigger Machine component to the prefab.

Box Collider #

Add a Box Collider component to the prefab’s root game object (Trap_Block) using the component menu.

The collider’s bounds shouldn’t cover the whole trap, so that it only activates when the player moves on it.

I’m using this setup.

  • Is Trigger
    Enable this setting.
  • Center
    Set to X=0, Y=1, Z=0.
  • Size
    Set to X=2.5, Y=2, Z=2.5.

Trigger Machine #

Add a Trigger Machine component to the same game object using the component menu.

Trigger machines start on trigger events, e.g. trigger enter.

Start Settings #

  • Trigger Enter
    Enable this setting.
    Starts when the player enter the game object’s trigger.
    Optionally, you can also start it when other game objects enter it (see the Starting Objects settings for this).

Machine Execution Settings #

Like with Interaction Machines we already used, this defines the schematic we’re using in the machine.

  • Schematic Asset
    Select the SpikeTrap schematic.

The rest of the settings can be kept as they are.

That’s it for the prefab setup – save the changes and return to the scene (i.e. close editing the prefab).

All traps in the scene now have our setup, let’s test it!

Testing #

Hit play directly in the scene and run into a trap.

It hurts – success!

Let’s finish up level 3.

Dungeon Level 3 #

We’ll add a level zone, item collectors (small key and additional items) and battles.

Level Zone #

Add a level zone either using the scene hierarchy context menu (ORK Framework > Zome > Level Zone (Scene)) or the Makinom scene wizard (Create Game Object > Level Zone (Scene)).

Level Settings #

  • Use Minimum Level
    Enable this setting.
  • Minimum Level
    Set to 10.
  • Set Levels
    Enable this setting.
  • Set Level
    Select Player.
  • Minimum Offset
    Set to -1.
  • Maximum Offset
    Set to 1.

Item Collector (Small Key) #

Add an item collector either via the scene hierarchy context menu (ORK Framework > Item Collector) or the Makinom scene wizard (Create Game Object > Item Collector).

Place the item collector on the crate in the upper center room.

Item Settings > Item 0 #

  • Item
    Select Small Key.

Battles #

Place battles using the Combatant Spawner Range prefab.

Adjust the Box Collider of the Move AI Range to fit the rooms the battles are placed in, rotate them as needed and select the groups you want to use.

I’m using:

  • 2x Physical DPS, 1x Mage
  • 1x Tank, 1x Mage, 1x Supporter
  • 1x Tank, 2x Physical DPS
  • 2x Physical DPS, 1x Supporter
  • 1x Physical DPS, 1x Mage
  • 2x Physical DPS
  • Dragon (single combatant)

The Dragon is placed by the small key’s item collector. To use a single combatant, change the following setting of the Combatant Spawner. Additionally, the battle with the dragon is moved a bit away from the spawner, to have the battle in the center of the room but the enemy sticking to the door.

Combatant Spawner > Combatant Settings > Combatant 0 #

Change the used group on the Combatant Spawner child object.

  • Use Group
    Disable this setting.
  • Combatant
    Select Dragon.

Additional Item Collectors #

Add some additional item collectors to the scene to have the player something to pick up and enjoy.

You can add item collectors either via the scene hierarchy context menu (ORK Framework > Item Collector) or the Makinom scene wizard (Create Game Object > Item Collector).

E.g. I’m adding:

  • High Potion x2
  • High Potion x3
  • Magic Potion x3
  • Magic Potion x3
  • Revive Potion x3
  • Revive Potion x3
  • Armor 2 x1
  • Staff 2 x1
  • Regen Charm x1
  • Sword 2 x1
  • Bow 2 x1
  • Gold x300

Enter Level 4 #

We’ll now update the trapdoor in the level 3 scene to load Dungeon Level 4 and add a spawn point in front of the trapdoor.

Scene Changer #

Select the Entrance_Trapdoor_Block game object in case it’s no longer selected.

Adjust the following setting.

Scene Change Settings > Scene Settings > Target Scene 0 #

  • Target Scene
    Set to Dungeon Level 4.

Spawn Point #

Create a Spawn Point in front of the trapdoor, either using the scene hierarchy context menu (Makinom > Spawn Point) or the Makinom scene wizard (Create Game Object > Spawn Point).

The spawn point automatically receives the spawn ID 1, since this is the next unused spawn ID. We’ll adjust the rotation for our player’s spawn.

Transform #

  • Rotation
    Set to X=0, Y=-90, Z=0.

Spawn Point #

  • Use Rotation
    Enable Y, disable X and Z.

That’s it for level 3 – don’t forget to save your changes.

Exit Level 4 #

Open Dungeon Level 4 (Assets/Scenes/Dungeon/), we’ll add a spawn point and scene changer to return to level 3.

Adding a Game Starter #

Don’t forget that you need to add a Game Starter to a scene if you want to do a quick playtest right in the scene.

Create an ORK Game Starter either using the scene hierarchy context menu (ORK Framework > ORK Game Starter) or the Makinom scene wizard (Add ORK Game Starter > Add ORK Game Starter).

It doesn’t really matter where you place the game starter, but make sure to enable Start Game for quick game testing.

  • Start Game
    Enable this setting.

Adding a Spawn Point #

Create a Spawn Point either using the scene hierarchy context menu (Makinom > Spawn Point) or the Makinom scene wizard (Create Game Object > Spawn Point).

Place the spawn point in front of the stairs leading upwards – but not too close, as we’ll also add a scene changer to the stairs.

Transform #

  • Rotation
    Set to X=0, Y=90, Z=0.

Spawn Point #

  • Use Rotation
    Enable Y, disable X and Z.

Adding a Scene Changer #

Select the Entrance_Staircase_Block game object – you can easily select it by clicking on the arch of the staircase.

The scene changer has to be added to the root game object (Entrance_Staircase_Block), not one of it’s child objects. Use the component menu to add a Scene Changer component.

Scene Change Settings > Scene Settings > Target Scene 0 #

  • Target Scene
    Set to Dungeon Level 3.
  • Position Type
    Select Spawn ID.
  • Spawn ID
    Select Value > Value.
  • Value (Spawn ID)
    Set to 1.

And that’s it for level 4 – don’t forget to save your changes.

Testing #

Make a test run of level 3 if you want – maybe increase the player’s start level when testing directly in the scene.

Next, we’ll go even deeper into the dungeon.