Build a Secret Lock with the Conditional Button
Unverified — this example may not compile as-is.
The Verse code below did not pass our automated compile check, so it isn't marked verified and is hidden from the guide listing. The explanation may still be useful, but treat the code as a draft and adapt it before use.
Build a Secret Lock with the Conditional Button
Do you like escape rooms? They are fun puzzles where you find keys to open doors. In Fortnite Creative, you can build your own secret lock. You will use a special device called the Conditional Button. It acts like a smart lock. It waits for you to find specific items. Then, it unlocks the door. Let's make a puzzle together!
What You'll Learn
- How to use the Conditional Button device.
- How to set Key Items Required.
- How to connect buttons to a Lock Device.
- How to hide clues using Holograms.
How It Works
Think of the Conditional Button like a treasure chest. A normal chest opens if you press it. A Conditional Button is smarter. It checks your backpack first. It asks, "Do you have the key items?"
If you have the items, it unlocks. If not, it stays locked. This is great for escape rooms. You can make players find torches or keys. They must collect them all. Then, they can press the button. The door opens!
You can also hide the button. You can make it invisible. Only the hologram shows up. This makes the game feel magical. Players do not know where the button is until they look closely.
The escape-room chain: find the key item, which enables the button, which tells the lock to open.
Let's Build It
We will build a simple escape room. You will need three things:
- A Lock Device on a door.
- A Conditional Button on the same door.
- Some Key Items (like torches) to find.
Here is how to set it up in UEFN.
Step 1: Place the Lock and Button
Place a Lock Device on your door. Place a Conditional Button next to it. The button should be easy to press.
Step 2: Set the Key Items
Click the Conditional Button. Look at its settings. Find Key Items Required. Set this number to 1. This means players need one item. For this tutorial, we will use torches.
Step 3: Enable the Button
By default, the button is off. We want it to stay off until the player finds the torch. Find Enabled at Game Start. Set this to No.
Now, we need a way to turn it on. We will use a Trigger Device. Place a Trigger Device near the torch. When a player touches the torch, the trigger fires. It sends a signal to the button.
Set the Trigger's Transmit On to a channel, like Channel 1.
Set the Conditional Button's Enable When Receiving From to Channel 1.
Now, when the player picks up the torch, the button turns on.
Step 4: Connect the Button to the Lock
The button needs to talk to the Lock Device. Find the Conditional Button's settings. Look for When Activated Transmit On. Set this to Channel 2.
Now, click the Lock Device. Find Open When Receiving From. Set this to Channel 2.
Now the chain is complete:
- Player finds torch.
- Trigger turns on button.
- Player presses button.
- Button tells Lock to open.
Step 5: Hide the Button (Optional)
You can make the button invisible. Find Visible During Game. Set it to Hologram Only. Now, players only see a floating icon. It looks like a secret!
Here is a simple Verse script to manage this logic. Note: In UEFN, you often use devices instead of code. But here is how it looks in Verse if you want to code it.
# This script makes a smart door lock
# It waits for the player to have a key item
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# A Verse device that wires a conditional_button_device
# to a door_guard_device (the closest real "lock" device in UEFN).
# note: UEFN exposes door_guard_device for locking/unlocking doors;
# there is no standalone LockDevice class in the public Verse API.
MySmartLock := class(creative_device):
# Drag-and-drop these in the UEFN outliner after placing the device.
@editable
MyDoorGuard : door_guard_device = door_guard_device{}
@editable
MyButton : conditional_button_device = conditional_button_device{}
@editable
MyItemGranter : item_spawner_device = item_spawner_device{}
# OnBegin runs automatically when the game session starts.
OnBegin<override>()<suspends> : void =
# Disable the button so players cannot press it yet.
MyButton.Disable()
# Subscribe to the button's activated event.
# When the conditional button decides all conditions are met
# and the player presses it, fire OnButtonActivated.
MyButton.ActivatedEvent.Subscribe(OnButtonActivated)
# Subscribe to the item spawner's pickup event so we know
# when the player collects the key item (the torch).
# note: item_spawner_device.ItemPickedUpEvent is the real event
# for detecting when a spawned item is collected.
MyItemGranter.ItemPickedUpEvent.Subscribe(OnKeyItemPickedUp)
# Runs when the player picks up the key item from the spawner.
OnKeyItemPickedUp(Agent : agent) : void =
# The player now has the key item, so enable the button.
MyButton.Enable()
# Runs when the player successfully activates the conditional button.
OnButtonActivated(Agent : agent) : void =
# Unlock the door by disabling the door guard.
# note: door_guard_device.Disable() removes the guard,
# allowing players to pass through the linked door.
MyDoorGuard.Disable()```
In this code, `MySmartLock` is the device class that manages everything. `MyDoorGuard` is the door lock. `MyButton` is the switch. `PickedUpEvent` watches for the player collecting the key item. `ActivatedEvent` listens for a successful button press. This is how computers think!
## Try It Yourself
Can you make a harder puzzle? Try this challenge:
1. Make the player need **two different items**. For example, a Red Key and a Blue Key.
2. Use two different triggers. One for the Red Key, one for the Blue Key.
3. Make the button stay locked until **both** triggers fire.
**Hint:** You can add more Key Items in the settings. Or, you can use two Conditional Buttons. Both must be enabled to open the door. Think about how to connect them!
## Recap
You built a smart lock! You used the Conditional Button device. You set it to wait for key items. You connected it to a Lock Device. Now you can make escape rooms. You can make mazes. You can make secret dungeons. Keep building!
## References
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/escape-room-key-mechanics-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/escape-room-key-gameplay-examples-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/mazey-escape-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/mazey-escape-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/create-a-dungeon-crawler-game-in-fortnite-creative
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add Using the conditional button device for puzzles to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.
References
Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.