πŸšͺ Door Logic | Open/Unlock when key collected

Collect to Open

Send a message when a key is collected to open one or more doors in range with the same tag.

Object 1 - :yellow_square: MP

Asset: Door
:label: Tags: Door

DOOR BEHAVIOR
:exclamation: Triggered by: Message
:inbox_tray: Trigger (Open): Key.Collected


Object 2 - :yellow_square: MP

Asset: Key

COLLECTABLE COMPONENT
:exclamation: Triggered by: Collect (collision)
:outbox_tray: Send: Key.Collected
:satellite: Broadcast Type: SpecificTagsInRange β†’ Door
:yellow_circle: Range: Adjust as needed*

*Adjust range so any doors to be opened by the key are located within the key’s yellow sphere. This indicates how far the key’s message can be sent.

Note

One key can open any door with the tag you choose using this method. You can use this schema multiple times to have multiple keys that only open certain doors for a fun challenge, like a maze.



Collect to Unlock

Instead of opening the door(s) when the key is collected, trigger a toggle component to unlock the door behavior(s), then interact with the door(s) to open. This feels more realistic.

Object 1 - :yellow_square: MP

Asset: Door
:label: Tags: Door

DOOR BEHAVIOR
:exclamation: Triggered by: Message
:inbox_tray: Trigger (Open): Interact

TOGGLE COMPONENT
:exclamation: Triggered by: Message
:inbox_tray: Trigger (On): Key.Collected


Object 2 - :yellow_square: MP

Asset: Key

COLLECTABLE COMPONENT
:exclamation: Triggered by: Collect (collision)
:outbox_tray: Send: Key.Collected
:satellite: Broadcast Type: SpecificTagsInRange β†’ Door
:yellow_circle: Range: Adjust as needed

2 Likes

Hey SandCultivator,
Below I implemented the β€œCollect to Open”.
Working great! Thank you!

# Lesson Dk01 - Door Opening by collecting a key

Send a message when a key is collected to open one or more doors in range with the same tag.

FLOWCHART:

LOGICs:

Asset name: Wooden Door (Basic)

Asset name: Gold Key (Basic)

Gameplay Result:
04262-ezgif.com-optimize

3 Likes

Hey SandCultivator,
Below I implemented the newcomer Tutorial fo β€œCollect to Unlock”.
Thank you @SANDcultivator

FlowChart:
When the key is collected, turn on the toggle component to activate the door’s behaviors.

With the door activated, the player can now open it.

Flowchart:

Gameplay:
2024-04-27_11-49-42-ezgif.com-optimize

2 Likes