Interactive Collectables Keys to unlock Doors

:mortar_board: TUTORIAL :mortar_board:

This mechanic consists of interacting with this key, choosing whether we want to lock or unlock the door, and collecting it by collision to place it in the inventory for use whenever desired.

Interactive Collectable Key Gameplay Video :point_down:

:mortar_board: Introduction

This tutorial and discussion, for educational purposes, is a step further from the tutorials related to using Doors, Toggle and keys. (LINK)

First, a basic concept within Game Maker is Interactive Collectables β€”those collectables that also allow some type of interaction. Here we will use a key that allows interaction through the β€œE” key, but it is collected by collision.

Interactive Collectable Key :point_down:

Assets :point_down:
1 Wooden Door (Basic)
2 Numpads (Yellow, White)
1 Ancient Lever (Basic)
1 Gold Key (Basic)

Logic :point_down:

:mortar_board: Logic Interpretation

In this logic, the yellow numpad is the UI information controller regarding whether the Door is locked, and the white one is if it is unlocked. The Lever is a universal lever to be the transmitter of messages to door opening checkers. The door itself has a normal toggle. The key has a Beh. Asker where the player will be asked whether they want to lock or unlock the door.

We can divide the logic into two parts. The first is the state of Lock and Unlock. The second is the activation of the door opening.

The first part, the information from the Asker, solidifies the Toggle state of Lock or Unlock in the following way:

Game Design :point_down:

Logic Flowchart :point_down:

In part 2, after the door state (Locked or Unlocked) is defined, we have the interaction with the Player using the Lever. At this moment, when interacting with the Lever to try to open the door, we have the following Game Design flowchart:

Game Design :point_down:

Logic Flowchart :point_down:

:mortar_board: Currently Limitations:
A limitations are related to when the key is dropped. Often, it is dropped far from the door, and we cannot carry it close to the door, where in this case we are using the key’s messages within a certain range.

:mortar_board: Future implementations and ideas.
(1) You can improve the Speaker Display by using this Tutorial here

(2) This mechanic is not polished, yet various mechanics related to keys can be implemented, including consumption, picking up, holding, and carrying them to the door, among many other methods. I can bring and teach several different methods, so feel free to suggest tutorials, send comments, ideas or share yours!

Best regards.
Dankoyy - L37