The Bus Drop: Your First Verse Script in UEFN
The Bus Drop: Your First Verse Script in UEFN
So you’ve finished the tutorials. You know how to place a wall, how to spawn a bot, and how to make a trap that actually triggers. But let’s be honest: if you just place a trigger and a damage zone, you’re playing Fortnite Creative 1.0. You want to make something that feels alive. Something that reacts to the player, not just waits for them.
That’s where Verse comes in.
Think of Verse as the director of your island. In standard Creative, you’re the stagehand, moving props around. With Verse, you’re the director, telling the props what to do when the camera rolls. We’re going to build a simple "Chaos Button." You press it, and the game gets weird. Specifically, we’ll make a button that, when pressed, instantly teleports every player on the island to the top of the map and spawns a chaotic storm. No complex math, no scary jargon. Just pure, unadulterated island chaos.
What You'll Learn
- Variables: How to store game state (like "is the button pressed?") using familiar concepts like health bars or ammo counts.
- Events: How to listen for player actions, just like a trigger zone listens for footsteps.
- Functions: How to package a set of actions (teleport + storm) into a single reusable command.
- Scene Graph Basics: Understanding that everything in your island is an "Entity" with "Components," just like a character has a mesh and a health component.
How It Works
Before we write a single line of code, let’s map this to mechanics you already know.
1. The Scene Graph: Your Island’s Skeleton
In UEFN, everything you see is part of the Scene Graph. Imagine the Scene Graph as the hierarchy of your island, much like how your inventory is organized into tabs (Weapons, Consumables, Misc).
- Entity: This is any object in your world—a prop, a player, a button, a storm zone. It’s like a single item in your inventory.
- Component: These are the properties attached to an Entity. A player Entity has a "Health" component, a "Mesh" component, and a "Movement" component. Think of Components as the stats or attachments on a piece of gear.
- Hierarchy: Entities can be parents or children. If you parent a light to a vehicle, the light moves with the vehicle. This is like equipping a skin to a character; the skin is part of that character’s hierarchy.
2. Variables: The Storm Timer
You know the storm timer? It’s a number that counts down. In programming, we call this a Variable. A Variable is a named container that holds a value that can change.
StormTimer = 120StormTimer = 119StormTimer = 118
In our script, we’ll use a variable to track if our Chaos Button has been pressed. It’s like a boolean switch (True/False) on a device. Is the button pressed? True. Is it not? False.
3. Events: The Trigger Zone
You know how a Trigger Zone waits for a player to step on it and then does something? That’s an Event. An Event is a signal that says, "Something just happened!"
- Event: Player steps on Trigger.
- Response: Deal damage.
In Verse, we write code that listens for events. We don’t tell the code what to do every frame (though we can); we tell it what to do when the button is pressed. It’s like setting up a trap: you don’t manually check every second if someone is in the trap; you set it to trigger when someone enters.
4. Functions: The Combo Move
You know how you can bind a complex combo (jump, edit, place, shoot) to a single key? That’s a Function. A Function is a block of code that performs a specific task. You can call it (execute it) whenever you want.
- Function Name:
PressChaosButton - Action: Teleport players, spawn storm, play sound.
We’ll wrap our chaos logic into a function so we can call it easily when the event happens.
Let's Build It
Here is a complete, minimal Verse script. It’s designed to be pasted into a Verse Device in UEFN. Don’t worry if you don’t see every single line; we’ll break it down below.
The Chaos Button Script
# This is a comment. The game ignores lines starting with #.
# We're defining a Device. Think of it as a new kind of prop you can place.
# It will have a "Pressed" event (like a button) and a "OnStart" event (when the island loads).
device Chaos_Button_Device:
# These are "Editable Properties". They show up in the UEFN sidebar.
# You can change them without touching code.
Pressed: event() = event() # This is the event that fires when the button is pressed
OnStart: event() = event() # This is the event that fires when the game starts
# This is a Variable. It stores the state of our chaos.
# IsChaosActive is a "Boolean" (True/False).
IsChaosActive: bool = false
# This is a Function. It’s our "Combo Move."
# It takes no inputs and returns nothing.
ActivateChaos() -> unit:
# If chaos is already active, don't do it again.
if IsChaosActive == true:
return # Stop the function here.
# Set the variable to true. Chaos is now ON.
IsChaosActive = true
# Get all players in the game.
# This is like saying "Get all players in the match."
all_players := GetPlayers()
# Loop through each player.
# Think of this like iterating through your squad list.
for player in all_players:
# Teleport each player to a specific location.
# We're using a built-in function: SetLocation.
# We'll teleport them to the top of the map (0, 0, 500).
player.SetLocation(Vector(0, 0, 500))
# Spawn a storm zone at their location.
# This is a simplified example. In real UEFN, you'd spawn a storm device.
# For this tutorial, we'll just print a message to the debug log.
Print("Chaos activated! Player teleported!")
# Play a sound effect (optional, but fun).
# PlaySound(ChaosSound) # Uncomment if you have a sound asset
# This is the main logic. It connects the events to the functions.
OnStart():
# When the island starts, we're ready.
Print("Chaos Button is live.")
Pressed():
# When the button is pressed, call our ActivateChaos function.
ActivateChaos()
Walkthrough: What Each Part Does
-
device Chaos_Button_Device:This line defines a new type of device. In UEFN, you’ll place a "Verse Device" prop, and this code tells it how to behave. It’s like defining a new gadget in your loadout. -
Pressed: event() = event()This declares an Event. When the button is physically pressed in the game, this event fires. It’s like the "Trigger" on a trap. -
IsChaosActive: bool = falseThis is our Variable. It’s a Boolean (True/False). We start it asfalsebecause chaos isn’t active yet. It’s like the storm not being active at the start of the match. -
ActivateChaos() -> unit:This is our Function.unitmeans it doesn’t return any value (like a void function). This is where the magic happens.if IsChaosActive == true: return— This prevents the chaos from happening twice. It’s like a cooldown. If the button is already pressed, do nothing.all_players := GetPlayers()— This gets a list of all players. Think of it as grabbing your squad list.for player in all_players:— This is a Loop. It goes through each player one by one, like checking each member of your squad.player.SetLocation(Vector(0, 0, 500))— This teleports the player.Vector(0, 0, 500)is a coordinate. X, Y, Z. We’re sending them to the top of the map.
-
Pressed():This is the Event Handler. It says, "When thePressedevent happens, call theActivateChaosfunction." It’s the link between the player’s action and the code’s response.
Try It Yourself
You’ve got the basics. Now, let’s make it harder.
Challenge: Modify the ActivateChaos function so that instead of teleporting players to the top of the map, it heals them to full health and gives them a random weapon.
Hint:
- Look for a function like
Heal()orSetHealth()on the player object. - Look for a function like
GrantWeapon()orGiveItem(). - You’ll need to import the weapon assets into your Verse device’s editable properties first, or use a hardcoded weapon name like
"WeaponAssaultRifle". - Remember: You can’t just call
Heal()without knowing how much to heal. Check the UEFN Verse documentation for the exact function signature.
Don’t worry if it breaks. That’s how you learn. Break it, fix it, break it again.
Recap
You just wrote your first Verse script. You learned that:
- The Scene Graph is the hierarchy of your island, like an inventory.
- Variables store changing values, like a storm timer.
- Events are signals that something happened, like a trigger zone.
- Functions are reusable blocks of code, like a combo move.
You didn’t just read about it; you built a Chaos Button. That’s real programming. And you did it without writing a single line of C++ or Java. You used the language of Fortnite.
References
- https://dev.epicgames.com/documentation/en-us/fortnite/build-a-game-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/uefn/build-a-game-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/learn-programming-with-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/sustainable-stacks-lesson-plan-for-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/sdg-sustainable-cities-lesson-plan-in-fortnite-creative
Verse source files
- 01-fragment.verse · fragment
Turn this into a guided course
Add build-a-game-in-unreal-editor-for-fortnite 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.