The Art of the Delay: How to Make Things Wait in Verse
The Art of the Delay: How to Make Things Wait in Verse
So you want to build a trap that doesn't just snap shut the millisecond someone steps on it? Or maybe you want a loot drop to appear after the boss dies, not before? That's where timing comes in. In Verse, we don't just "wait." We tell the game engine to pause that specific line of code for a set amount of time while letting everything else keep running. It's the difference between a trap that feels instant (and cheap) and one that feels tense, deliberate, and fair.
We're going to build a simple Delayed Loot Drop. You'll place a button, and five seconds later, a crate appears. No triggers, no complex logic chains—just pure, unadulterated timing.
What You'll Learn
- The
SleepCommand: How to pause code execution for a specific number of seconds. - Async vs. Sync: Why waiting doesn't freeze your entire island (the "Battle Bus" analogy).
- Spawning Props: Instantiating a 3D object into the world using Verse.
How It Works
Imagine the game engine is like the Battle Bus dropping players onto the island. The bus doesn't wait for one player to find their gear before it drops the others. It drops everyone, and then each player's journey happens independently.
In programming, this is called asynchronous execution. If you tell Verse to "wait 5 seconds," it doesn't freeze the whole game. It just pauses that specific instruction. The rest of the island—other players moving, storms closing, bullets flying—keeps going.
Think of Sleep like a Storm Timer. When the storm starts moving, the timer counts down. During those seconds, the storm isn't doing anything yet (it's just counting), but the players are still running around, building, and shooting. Once the timer hits zero, then the damage kicks in.
In Verse, we use the Sleep function from the Simulation library. You pass it a number (in seconds), and it says, "Hey, pause here for this long, then come back to the next line."
Let's Build It
We're going to create a custom component. This is a small script attached to an object that tells it what to do.
The Setup:
- Open UEFN.
- Place a Button device in your island.
- Right-click the Button and select Add Component -> New Verse Component.
- Name it
DelayedLootComponent. - Paste the code below into the editor.
# We need access to the Simulation library to use Sleep,
# and World to spawn our loot.
using { /Verse.org/Simulation }
using { /Verse.org/Native }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Devices }
# This is our "Loot Goblin" component.
# It attaches to a Button device and waits to spawn a crate.
#
# HOW TO SET UP IN UEFN:
# 1. Place a button_device in your level.
# 2. Place a prop_mover_device in your level; set its
# initial state so the crate is hidden off to the side.
# 3. Select the button_device, click Add -> New Verse Component,
# and choose this file.
# 4. In the component's Details panel, drag your prop_mover_device
# into the TargetProp slot.
loot_goblin_component := class(creative_device):
# Editable reference: drag your PropMover into this slot
# in the UEFN Details panel.
@editable
TargetProp : prop_mover_device = prop_mover_device{}
# Editable reference: drag your Button device into this slot.
@editable
LootButton : button_device = button_device{}
# OnBegin wires up the button's InteractedWithEvent so we
# respond whenever any player presses it.
OnBegin<override>()<suspends> : void =
LootButton.InteractedWithEvent.Subscribe(OnButtonPressed)
# When the button is pressed, this function fires.
# Think of this as the "Trigger" on a trap.
# <suspends> lets us call Sleep without freezing the game.
OnButtonPressed(Agent : agent) : void =
spawn:
WaitThenSpawnLoot()
WaitThenSpawnLoot()<suspends> : void =
# 1. Tell the player something is happening.
# Print acts like a chat message or system notification.
Print("Loot is coming... get ready!")
# 2. The Magic Pause.
# We tell the simulation to wait 5.0 seconds.
# The game does NOT freeze. Other players can still move.
Sleep(5.0)
# 3. After the 5 seconds are up, activate the PropMover.
# The PropMover should be configured in UEFN to move
# the crate into its visible, final position when activated.
TargetProp.Begin()
# 4. Let the player know the loot is here.
Print("Loot dropped! Go get it!")```
*Wait, hold up.* Spawning props dynamically can get tricky with asset IDs if you don't have them handy. Let's make this **even simpler** and more robust for a beginner. We'll use a **PropMover** that is already placed in the world, hidden, and we'll make it appear after the wait.
Here is the **Revised, Playable Code**:
```verse
using { /Verse.org/Simulation }
using { /Verse.org/Native }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Devices }
# HOW TO SET UP IN UEFN:
# 1. Place a button_device in your level.
# 2. Place a prop_mover_device in your level.
# In its settings, position the prop off-screen or set
# "Start Hidden" so it begins invisible.
# 3. Select the button_device, click Add -> New Verse Component,
# choose this file, then in the Details panel drag:
# - your button_device -> LootButton
# - your prop_mover_device -> TargetProp
delayed_loot_component := class(creative_device):
# We need a reference to the PropMover we placed in the world.
# In UEFN, drag the PropMover into the 'TargetProp' slot in
# the component properties panel.
@editable
TargetProp : prop_mover_device = prop_mover_device{}
# Editable reference to the Button device in the level.
@editable
LootButton : button_device = button_device{}
# OnBegin runs once at game start and subscribes to the button.
OnBegin<override>()<suspends> : void =
LootButton.InteractedWithEvent.Subscribe(OnButtonPressed)
# Fires whenever any agent (player) interacts with the button.
OnButtonPressed(Agent : agent) : void =
# spawn: launches WaitThenDropLoot as its own async task so
# the button stays responsive and the game never freezes.
spawn:
WaitThenDropLoot()
# <suspends> marks this as an async function — required for Sleep.
WaitThenDropLoot()<suspends> : void =
# 1. Immediate Feedback
Print("Loot is loading...")
# 2. The Wait.
# Sleep(5.0) pauses ONLY this coroutine for 5 seconds.
# The rest of the game keeps running.
Sleep(5.0)
# 3. The Action — activate the pre-placed PropMover.
# Activate() tells the PropMover to move/reveal the prop.
TargetProp.Activate()
Print("Loot is here!")
verse
# Inside a <suspends> function:
Print("Triggered!")
Sleep(2.0)
Print("BOOM!")
# Add your trap activation here — e.g. TrapProp.Activate()
Recap
Sleep(seconds)pauses a script for a set time without freezing the game.- It's asynchronous, meaning other players and systems keep working while you wait.
- Any function that calls
Sleepmust be marked<suspends>. - Use
spawn:to launch a<suspends>function as its own independent task from a non-suspending context. - Use it to create tension, delays, or timed events like loot drops or trap springs.
References
- https://dev.epicgames.com/documentation/en-us/uefn/creating-your-own-component-using-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/creating-your-own-component-using-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/verse-api/versedotorg/simulation
- https://dev.epicgames.com/fortnite/verse-api/versedotorg/simulation
- https://dev.epicgames.com/documentation/en-us/fortnite/using-third-person-controls-devices-in-fortnite-creative
Get the complete code — free
You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.
Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.
Verse source files
- 01-device.verse · device
- 02-device.verse · device
- 03-fragment.verse · fragment
Turn this into a guided course
Add Wait 5 seconds 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.