Boom Goes the Map: Building Explosive Traps with Verse
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.
Boom Goes the Map: Building Explosive Traps with Verse
Stop letting players walk right past your secret base. It’s time to turn your island into a chaotic minefield. In this tutorial, we’re ditching the tedious point-and-click device linking and writing a custom Verse script to build a Smart Explosive Barrel. This barrel won’t just sit there looking pretty; it will warn players with a bubbling visual effect, count down the seconds, and then boom, sending anyone nearby flying.
We’ll learn how to manage game entities (the things in your world), bind events (making things happen when something else happens), and control time. By the end, you’ll have a working trap that feels like it belongs in a professional competitive map.
What You'll Learn
- Entities: Understanding the "actors" in your scene graph (props, devices, players).
- Event Binding: Connecting a trigger (input) to an explosion (output) using code.
- Timers: Creating delays and countdowns without manually wiring up five different timer devices.
- Visual Feedback: Using VFX (Visual Effects) to warn players before they get wrecked.
How It Works
In Fortnite Creative, you’re used to dragging an Explosive Device onto the island and wiring it to a Trigger. That works fine for simple traps, but what if you want the barrel to glow red and bubble for three seconds before it blows up? Or what if you want to reset the trap automatically after it explodes?
That’s where Verse comes in. Think of Verse as the Game Designer sitting behind the scenes. You don’t touch the wires directly; you tell the Game Designer, "Hey, when a player steps on this tile, start a 3-second countdown. When the timer hits zero, play a fire effect, deal damage to everyone in a 10-meter radius, and then destroy the barrel."
The Scene Graph: Your Island’s Skeleton
Before we code, we need to understand the Scene Graph. Imagine your island is a giant tree. The root is the game world. Branches are rooms or zones. Leaves are individual objects like a barrel, a player, or a light. In Verse, every object you interact with is an Entity.
- Entity: Any object in the game world (a barrel, a player, a device).
- Component: The traits an Entity has (Health, Position, Mesh/Shape).
We aren’t just placing a prop; we are attaching logic to that prop.
The Logic Flow
- Listen: We create a "Listener" (an event) that watches for a player entering a specific zone.
- Warn: When triggered, we spawn a visual effect (VFX) on the barrel to simulate bubbling.
- Wait: We pause the script for 3 seconds.
- Detonate: We apply damage to all entities in the blast radius.
- Clean Up: We remove the barrel so it doesn’t block the path forever (or we could respawn it, but let’s keep it simple: it’s a one-time trap).
Let's Build It
We are going to write a script that turns a simple barrel into a ticking time bomb.
Prerequisites
- Open Unreal Editor for Fortnite (UEFN).
- Create a new Island or open an existing one.
- Place a Prop (a barrel) in the world. Let’s call it
BombBarrel. - Place a Trigger (Volume Trigger) around the barrel.
- Create a new Verse file in the Content Browser. Name it
SmartBomb.
The Code
Copy this code into your SmartBomb.verse file. Don’t worry if it looks alien; we’ll break it down line by line.
# SmartBomb.verse
# A script that turns a barrel into a timed explosive trap
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is the main "Actor" class for our trap.
# Think of this as the blueprint for our Smart Bomb.
smart_bomb_device := class(creative_device):
# These are the "Components" we need to make it work.
# We'll assign these in the editor later.
MyExplosiveDevice: explosive_device = explosive_device{}
vfx_creator: vfx_creator_device = vfx_creator_device{}
trigger_zone: trigger_device = trigger_device{}
# This function runs when the device is placed in the world.
OnBegin<override>()<suspends>: void =
# 1. Listen for players entering the trigger zone.
# "TriggeredEvent" is the event (the input).
# We bind our custom function "StartDetonation" to it.
trigger_zone.TriggeredEvent.Subscribe(Start_Detonation)
# This function is called when the trigger is activated.
Start_Detonation(triggered_agent: ?agent): void =
# 2. Visual Warning: Play the "Bubbling" VFX on the barrel.
# We assume the barrel has a VFX Creator attached or we spawn one.
# For simplicity, let's just signal the VFX device to play a "Warning" effect.
vfx_creator.Begin()
# 3. Wait for 3 seconds and then detonate using a spawned async task.
# "Sleep" pauses this script for the specified time, but since
# Start_Detonation does not have the 'suspends' effect, we spawn
# a coroutine to handle the timed sequence.
spawn:
# 3. Wait for 3 seconds.
Sleep(3.0)
# 4. Detonate!
# "Explode" sends the explosion signal to our explosive device.
if (A := triggered_agent?):
MyExplosiveDevice.Explode(A)
# 5. Cleanup: Remove the barrel after a short delay so it doesn't linger.
Sleep(1.0)
# Note: In a real scenario, you might want to destroy the prop entity here.
# For this basic example, the explosion device handles the damage.```
### Walkthrough: What Just Happened?
1. **`class(creative_device)`**: This defines our script. In UE6/Verse, everything is an Entity. By inheriting from `creative_device`, we’re saying, "This script controls a device in the game world."
2. **`OnBegin<override>()`**: This is the **Initialization**. It runs once when the island starts. It’s like the pre-game lobby. Here, we use `.Bind()` to connect the **Event** (`OnPlayerTriggered`) to our **Function** (`Start_Detonation`). This is the core of Verse: Event-Driven Programming. You don’t check "is player here?" every frame; you wait for the notification that they *are*.
3. **`Wait(3.0)`**: This is the timer. In traditional device linking, you’d need a separate Timer device wired to a Delay. In Verse, `Wait` simply pauses the execution of this specific script for 3 seconds. It doesn’t freeze the whole game, just this bomb’s logic.
4. **`.Fire()`**: This is how we tell devices to do stuff. `explosive_device.Fire("Explode")` is the digital equivalent of pulling the pin on a grenade.
### Setting It Up in the Editor
Code is useless if it doesn’t know which barrel to blow up.
1. Place your **Explosive Device** near the barrel.
2. Place your **VFX Creator** near the barrel.
3. Place your **Trigger Volume** around the barrel.
4. In the World Outliner, find your **Smart Bomb** device (you may need to create a custom device type or attach this script to an existing device slot if your UEFN version supports it directly, or better yet, attach this logic to a generic **Creative Device** and assign the references).
* *Note: In current UEFN workflows, you often attach this script to a blank **Creative Device** placed in the world.*
5. Select the Creative Device holding the script.
6. In the Details Panel, you will see the variables we defined: `explosive_device`, `vfx_creator`, and `trigger_zone`.
7. Drag and drop the corresponding devices from your scene into these slots.
Now, when a player steps on the trigger, the VFX plays, the script waits 3 seconds, and the explosive device fires.
## Try It Yourself
The current script is a bit simple—it only works once and doesn’t destroy the barrel. Here’s your challenge:
**Challenge:** Modify the script so that after the explosion, the barrel disappears (is destroyed) and a new barrel spawns in the same location after 5 seconds, making it an infinite trap.
*Hint: Look up the `Destroy()` function for entities and how to use `Wait` to respawn an object. You’ll need to reference the barrel’s entity directly.*
## Recap
You’ve just built a smart trap using Verse. You learned that:
1. **Entities** are the objects in your world.
2. **Events** (like triggers) notify your script when something happens.
3. **Functions** (like `Start_Detonation`) are the actions you take in response.
4. **Timers** (`Wait`) let you control the pace of gameplay without complex device wiring.
Verse gives you the power of a game designer without the spaghetti wiring of device links. Now go make some chaos.
## References
- https://dev.epicgames.com/documentation/en-us/fortnite/using-explosive-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-explosive-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-explosive-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/explosive-device-design-example-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/explosive-device-design-example-in-fortnite-creative
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add using-explosive-devices-in-fortnite-creative 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.