Basic Tutorials

Obstacle Game Mini-series #2: The Locked Door

Welcome to the second tutorial in the Obstacle Game Miniseries. This is a continuation from Obstacle Game Miniseries #1, which introduces this series and guides you through building an intriguing entrance to the level.

In this tutorial you will:

  1. Add a locked door which can be opened by jumping on a floor switch
  2. Create automatic doors

Adding A Locked Hatch

The Player is on the roof, which means we can make them take an exciting drop into a new area. The obstacles in this section will use the same tools used to open doors explored in Basic Tutorial 2: Events, but in a slightly different way.

To start with, add a turn to your roof, and use the turn as an opportunity to increase the difficulty from Very Easy to Easy – the new pathway should be 6 – 10 Voxels wide.

It’s good to have areas of your level that are not too demanding. The blank space gives the player a chance to recover after a difficult challenge, and you can always add interesting visual elements when you come to dress the level later on.

Now it’s time to add a loft hatch. To do this, we are going to use the Smash-n-Grab Tutorial Package. Open the Library and enter the Community tab.

Install the Smash-n-Grab Tutorial package.

Return to the Library and open the Meshes tab. Add the Vault Door to your Hotbar.

Close the Library.

Place the Vault Door mesh at the end of your rooftop pathway.

Open the Entity Editor for the Vault Door and move and rotate it so that it is lying flat attached to the end of the roof.

Use the Voxel tools to build a setting around it. To save time you may want to place a starting voxel on each edge and then use the extrude tool to expand the length.

Continue your narrow rooftop path past the Vault Door. The Player will solve this puzzle by doubling back on themselves.

Creative Control: Your own path

Whilst this tutorial guides you through making a basic level structure, the details of the level are entirely up to you. You can copy this exactly, or you can make yours more or less difficult by creating more difficult pathways to navigate.

Open the Library and navigate to the Meshes tab and add the Pad (Pressure) mesh to your Hotbar.

Close the Library and add the Pad (Pressure) to the end of the narrow pathway.

Open the Entity Editor for the Pad (Pressure) to fine-tune it’s position.

Position it slightly below floor level. This way the Player will run onto it seamlessly.

Adding the Pad (Pressure) at the end of this rooftop will give us a great opportunity to create a spectacular view later on!

As you did with the Vault Door, use the Voxel tools to build around it, embedding it within the roof.

That’s the positioning taken care of, now to add the functionality. We will be repurposing the LockedDoor Script from the Smash-n-Grab Tutorial package we installed earlier.

Open the Entity Editor for the Vault Door.

Select “Add to Entity”.

Select Add > Script > LockedDoor.

You can add Sounds to this later, but for now leave the LockedDoor Script Properties blank.

Close the Entity Editor for the Vault Door and open the Entity Editor for the Pad (Pressure).

Click the “+” icon next to the onCollision Property.

Click the arrow next to “Entity” and select the bankVaultDoor from within the terrain object.

The Script should be automatically set to the LockedDoor Script attached to the Vault Door when you select the bankVaultDoor Entity.

Select the OpenDoor(overrideLock) function as the Event.

Close the Entity Editor and test the functionality by Previewing the game.

You should find that when you jump on the Pad (Pressure) the door opens. If it doesn’t open, make sure that you are jumping on the pad (it can take a bit of force to run the onCollision event for the Pad (Pressure).) and then double check that you have hooked up the Properties the same as above.

Stop the Preview and return to the Editor mode.

Now to add some drama to your game by building a shaft below the Vault Door so that when the player enters it they will freefall. 

Tech Tip: DeathZ

Before we give the Player a drop to the next section, it is worth highlighting a technical aspect of game development – the deathZ (also called a death plane)!

By default, the DeathZ Game Property is set to -1000. This means that if your Player’s Z-Position gets to -1000 then they will die, and they will respawn at the start. If deathZ didn’t exist, the Player would fall forever, and Crayta would be full of Players stuck infinitely falling to their deaths! 

This Property is possible to edit in Advanced Mode (if that is accessible to you). If you don’t have access to Advanced Mode, make sure that your terrain does not go below -1000 on the Z-Axis. You may need to check your shaft to ensure the Player isn’t killed by jumping in! 
If you can’t (or don’t want to) enter Advanced Mode, select the terrain Entity and move the whole terrain up, including the Players spawn Locator which you can find where the Player is spawned currently.

To build the shaft, position your Drone view underneath the Vault Door. Use the Voxel tools to build 1 Voxel wide wall around the edge of your Vault Door.

Use the Extrude tool to extend the shaft down.

At the bottom, continue three sides of your shaft to create an opening.

Add a floor to the bottom of the shaft.

Extend the floor beyond the shaft to create a pathway out of the shaft.

Adding Automatic Doors

Open the Library and navigate to the Meshes tab. Add the Office Door mesh to your Hotbar.

Close the Library.

Add the Office Door to the exit of the shaft.

Use the Voxel tools to build a corridor around the door.

This door marks the entry to a new area of the map, and will give some context to Checkpoint2. You will use a trigger and the LockedDoor script to make this door open automatically when the player gets near it.

Open the Library and navigate to the Primitives tab.

Add the Trigger to your Hotbar.

Add a Trigger just in front of the door.

Open the Entity Editor for the Trigger.

Change the size of the Trigger so that it is the entire area behind the door.

Open the Entity Editor for the Office Door and add the LockedDoor Script.

And now open the Entity Editor for the Trigger once again. Click on the “+” next to onTriggerEnter.

Select the Office Door Entity and the OpenDoor() function of the LockedDoor Script.

Finally you need to add Checkpoint2 to the other side of this door. Use the Voxel tools to extend the floor.

Make sure you have the Select tool enabled (press B if you still have Voxel tools). Fly your drone to find Checkpoint2 from the original level.

Press RT to pick up the Checkpoint2 (make sure to select the Checkpoint and not an individual aspect of it – again use the tool descriptions in the bottom left that tell you what you’re editing).

Move it to the pathway on the other side of the Office Door.

Use the Entity Editor to fine-tune the position of the Checkpoint2 (remember the standard grid settings is based on multiples of 25cm.)

Preview your game and test your new obstacles.

Next Steps: Obstacle #3

Success! You have just added two new doors to your game. Now that you have presented your Player with a simple challenge you can start to ramp up the difficulty and move on to creating some more difficult obstacles.

Obstacle Game Mini-series #3: Spinning Saws