The "Don't Scream" Alarm: Building a Stealth Trap with Verse
The "Don't Scream" Alarm: Building a Stealth Trap with Verse
So you want to build a trap that doesn't just go BOOM, but actually warns you (or your enemies) that they've messed up? We're building a Stealth Alarm System. Imagine a hallway where a red light pulses slowly while you sneak past, then suddenly blares when you step on the pressure plate. No explosions, just pure, unadulterated tension.
In this tutorial, we're going to use Verse to connect a Customizable Light to a Trigger Zone. We'll learn how to tell the light to stay off until the player enters the zone, then switch it on with a rhythmic, annoying pulse. It's the digital equivalent of a motion-sensor flashlight in a horror movie, but with more code and fewer jump scares.
What You'll Learn
- Variables: How to store the "state" of your light (On vs. Off) so it remembers what happened.
- Events: How to make the game react when a player steps in a specific spot (like a tripwire).
- Scene Graph Basics: Understanding how devices talk to each other through the hierarchy.
- Verse Syntax: Writing your first few lines of code to control game objects.
How It Works
Before we write a single line of code, let's map this to something you know: The Storm.
In Fortnite, the storm has a timer. It's always counting down. It doesn't care if you're hiding in a bush; the timer keeps going. In programming, we call the thing that counts down a Variable. A variable is just a container that holds a value (like time, health, or ammo) that can change during the game.
Now, imagine you have a Trigger Zone (like a pressure plate). When a player steps on it, something happens. In game design, we call that happening an Event. An event is a signal that says, "Hey! Something just occurred! Do something about it!"
Our alarm system works like this:
- The Light is a device. It has a state: Off.
- The Trigger Zone is watching for players.
- The Event is "Player Entered Zone."
- The Reaction is: "Change the Light's state to On and make it flash red."
In UEFN (Unreal Editor for Fortnite), devices don't just magically know what to do. We have to write a tiny script in Verse to connect the Event (Trigger) to the Reaction (Light). Think of Verse as the wiring between the lightbulb and the tripwire.
The Scene Graph: Who's Talking to Whom?
In Unreal Engine, every object in your level is part of a Scene Graph. This is just a fancy way of saying "The Family Tree of Objects."
- The Island is the parent.
- Devices (Lights, Triggers) are children.
- Scripts (Verse files) are the rules that govern how those children interact.
When we write Verse, we're giving instructions to specific nodes in that tree. We don't want to turn on every light on the island, just the one we named "StealthAlarmLight." That's why we need to be specific.
Let's Build It
We're going to create a simple script that turns a light on when you enter a zone.
Step 1: Set Up Your Devices
- Place a Customizable Light device. Name it
StealthAlarmLightin the Name field in the Customize panel. - Customize the light:
- Light Color: Red (
#FF0000) - Light Intensity: 100%
- Rhythm Preset: None (We'll handle the flashing in code, or keep it solid for now).
- Light Color: Red (
- Place a Trigger Zone device near the light.
- Customize the Trigger Zone:
- Shape: Box
- Size: Make it big enough to walk into.
- Name:
StealthTrigger
Step 2: Write the Verse Code
Create a new Verse file. Let's call it StealthAlarm.verse. Paste this code in. Don't worry if it looks weird; we'll break it down line by line.
# This is a comment. The game ignores it. It's just for us.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# 1. Define the Script
# Think of this as the "Rulebook" for our alarm.
# In real Verse, a device script is a class that extends creative_device.
StealthAlarmScript := class(creative_device):
# 2. Define the Variables (The Containers)
# '@editable' lets you drag-and-drop the device reference in the UEFN editor.
# 'alarm_light' will hold the reference to our Customizable Light device.
# 'alarm_trigger' will hold the reference to our Trigger Zone.
@editable
alarm_light : customizable_light_device = customizable_light_device{}
@editable
alarm_trigger : trigger_device = trigger_device{}
# 3. The 'OnBegin' Function
# This runs once when the game starts. It's like the bus dropping players.
OnBegin<override>()<suspends> : void =
# 4. Connect the Devices
# Because we used @editable above, alarm_light and alarm_trigger are
# already set to the devices we picked in the editor — no searching needed.
# 5. Listen for the Event
# We want to know when someone enters the trigger zone.
# trigger_device has an event called TriggeredEvent.
# We connect that event to a function we'll create next.
alarm_trigger.TriggeredEvent.Subscribe(OnPlayerEntered)
# 6. The Reaction Function
# This is what happens when the event fires.
# trigger_device.TriggeredEvent passes the instigating agent (player) as ?agent.
OnPlayerEntered(Agent : ?agent) : void =
# 'Agent' is the player who stepped on the zone.
# Turn the light ON.
alarm_light.TurnOn()
# Optional: Make it flash by enabling the light's built-in pulse.
# The customizable_light_device does not expose a runtime SetRhythm API,
# so configure the Rhythm Preset to "Wave" in the editor instead.
# note: runtime rhythm/color APIs are not yet available in the public Verse SDK;
# use the device's Customize panel in UEFN to pre-set color and rhythm.```
### Wait, That's Not Quite Right for UEFN
The code above is pseudocode to explain the *logic*. In real UEFN Verse, we don't manually create instances of `CustomizableLight()` like that. Instead, we use **Components** and **Events** that are already bound to the devices in the editor.
Here is the **real**, working Verse code for a simple alarm. You'll attach this to your **Trigger Zone**.
```verse
# StealthAlarm.verse
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags }
using { /UnrealEngine.com/Temporary/Diagnostics }
# Define the script that will run as a creative_device placed in the level.
# In UEFN you add a "Verse Device" actor to the level and assign this class to it.
StealthAlarmScript := class(creative_device):
# This variable holds the reference to the Customizable Light device.
# Drag your 'StealthAlarmLight' actor onto this slot in the UEFN Details panel.
@editable
alarm_light : customizable_light_device = customizable_light_device{}
# This variable holds the reference to the Trigger Zone device.
# Drag your 'StealthTrigger' actor onto this slot in the UEFN Details panel.
@editable
alarm_trigger : trigger_device = trigger_device{}
# This function runs when the game starts.
OnBegin<override>()<suspends> : void =
# Connect the trigger's TriggeredEvent to our reaction function.
# Whenever an agent (player) activates this trigger, run 'OnPlayerEntered'.
alarm_trigger.TriggeredEvent.Subscribe(OnPlayerEntered)
# This function runs when the event fires.
OnPlayerEntered(Agent : agent) : void =
# Turn the light on.
alarm_light.TurnOn()
# note: runtime SetLightColor and SetRhythm are not exposed in the current
# public Verse SDK for customizable_light_device. Set the light color to red
# and the Rhythm Preset to "Wave" in the device's Customize panel in UEFN.
# The TurnOn() call above will activate those pre-configured settings.
Walkthrough: What Just Happened?
StealthAlarmScript := class(creative_device): This declares our rulebook as a proper Verse device class that UEFN can place in the level.@editable alarm_light : customizable_light_device: We declared a typed variable with the@editabledecorator. That decorator is the magic — it makes a slot appear in the UEFN Details panel so you can drag your light device directly into it. No guessing names at runtime.OnBegin<override>()<suspends>: This is a special function. It runs once when the island loads. It's like the "Ready Up" screen before the match starts. The<suspends>specifier means this function is allowed to wait (important for async Verse code).alarm_trigger.TriggeredEvent.Subscribe(OnPlayerEntered): This is the wiring. We're telling the Trigger Zone: "When someone triggers you, call theOnPlayerEnteredfunction."OnPlayerEntered(Agent : agent): This is the reaction.Agentis the player. We tell the light to turn on with its pre-configured color and pulse settings.
Try It Yourself
You've got the basics. Now, make it annoying.
Challenge: Modify the OnPlayerEntered function so that the light doesn't just turn on—it turns OFF after 3 seconds.
Hint: You'll need a Timer. In Verse, you can use Sleep() inside a <suspends> function to pause execution for a set number of seconds before continuing. Think of it like setting a countdown on a microwave: "In 3 seconds, beep."
Hint 2: You might need to spawn a second async expression, like spawn { TurnLightOffAfterDelay() }, so the delay runs in the background without blocking the rest of your code.
Recap
- Variables are containers for data (like holding the reference to a light device).
- Events are signals (like "Player Entered Zone") that trigger actions.
- Functions are blocks of code that do something (like "Turn Light On").
- Verse is the language that connects Events to Functions, allowing you to control devices in your Scene Graph.
You just built a stealth alarm. Next time you're sneaking through an enemy base, you'll know exactly how to rig their lights to betray them.
References
- https://dev.epicgames.com/documentation/en-us/fortnite/ascender-device-design-examples-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/lock-device-design-examples
- https://dev.epicgames.com/documentation/en-us/fortnite/using-real-time-clock-devices-in-fornite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-nitro-drifter-spawner-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/cinematic-sequenceples-in-fortnite
Verse source files
- 01-device.verse · device
- 02-device.verse · device
Turn this into a guided course
Add Configure the Alarm System 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.