The Blueprint of Chaos: Building Your First Verse Component
The Blueprint of Chaos: Building Your First Verse Component
You know how you can drag a "Jump Pad" into your island, tweak its settings, and suddenly you’ve got a physics-based chaos machine? That’s UEFN being awesome. But what if you want a trap that only triggers when three people are standing on it, or a loot box that changes color based on how many eliminations you’ve racked up? That’s where Verse comes in.
Think of Verse as the wiring inside the walls. You don’t need to be an electrician to flip a light switch, but if you want to build a smart home that turns off the lights when you leave the room, you need to know how to connect the wires. In this tutorial, we’re going to skip the boring "Hello World" stuff. Instead, we’re going to build a "Chaos Button." When you press it, it spawns a random prop above your head. It’s simple, it’s stupid, and it’s the perfect way to learn how Verse talks to your island’s scene.
What You'll Learn
- The Scene Graph: Why your island is a giant family tree of objects (and why that matters).
- Variables: How to store data like a loot drop count.
- Functions: How to package a sequence of actions into a single button press.
- Components: How to attach custom Verse logic to standard Fortnite props.
How It Works
Before we write a single line of code, we need to understand the universe we’re working in. In old-school game design, you might just place objects randomly. In Unreal Engine 6 (and UEFN), everything is part of the Scene Graph.
Imagine your island is a massive, nested set of Russian dolls.
- The Outer Doll is your Island.
- Inside that is a Room.
- Inside the Room is a Prop (like a barrel).
- Inside the Barrel is a Component (like a light or a script).
In programming terms:
- Entity: Any object in the world (a barrel, a player, a trigger zone). It’s the "thing" itself.
- Component: A piece of functionality attached to an Entity. Think of it like an accessory. A player is an Entity; their "Health" is a Component. Your custom Verse script is also a Component.
When you write Verse, you aren’t just writing code; you’re building Components that you slap onto Entities. If you want your Chaos Button to work, you need to tell the engine: "Hey, when this specific button Entity gets pressed, run this Component’s script."
The "Loot Drop" Analogy for Variables
You know how a loot drop has a specific rarity? Common, Rare, Epic? That’s a Variable.
A Variable is just a labeled box where you store a piece of information that can change.
CurrentHealthis a box that holds the number100.LootRarityis a box that holds the word"Epic".
In our Chaos Button, we don’t need complex data yet. We just need to know when to spawn stuff. But understanding that code interacts with these "boxes" of data is step one.
The "Trap Trigger" Analogy for Functions
You know how a Trigger Zone works? You walk into it, and boom, the trap fires. That’s a Function.
A Function is a named block of code that does a specific job. You can call it (trigger it) from anywhere.
SpawnProp()is a function that says, "Go find a random prop and put it in the world."PlaySound()is a function that says, "Make a loud noise."
We’re going to combine these. We’ll create a function called OnButtonPressed that tells the game to spawn a prop.
Let's Build It
We are going to create a single Verse component that you can attach to any button in your island. When pressed, it will spawn a random prop (like a barrel or a crate) directly above the button.
Step 1: Create the Script
- Open Unreal Editor for Fortnite (UEFN).
- Go to the Content tab.
- Click New > Verse Script.
- Name it
ChaosButton.
Step 2: The Code
Copy and paste this code into your new script. Don’t worry about memorizing it yet; we’ll break it down line by line.
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Symbols }
# This is our "Component" definition.
# It tells the engine what data this script needs.
ChaosButtonComponent := component (
# We need a reference to the world to spawn things
World: world,
# We need a reference to the transform (position/rotation) of this component
Transform: transform,
# A simple flag to know if the button was pressed
ButtonPressed: bool = false
)
# This is the main function. Think of it as the "Brain" of the component.
# It runs every time the game checks in (or when we tell it to).
main := func (component: ChaosButtonComponent) -> void:
# Check if the button has been pressed
# In a real device, we'd link this to an event, but for this demo,
# we'll simulate a press via a simple trigger logic below.
# If the button is pressed, we spawn a prop
if component.ButtonPressed == true:
# 1. Get the current position of the button
CurrentLocation := component.Transform.GetLocation()
# 2. Move it up by 200 units (so it doesn't spawn inside the button)
SpawnLocation := CurrentLocation + vec(0, 0, 200)
# 3. Pick a random prop type (Barrel, Crate, or Turret)
# We use a random number generator to pick an index
RandomChoice := rand(3)
# 4. Based on the random choice, we "spawn" a simple visual block
# Note: In a full game, you'd use SpawnActor, but for this simple
# component demo, we'll just log it to the console to prove it works.
# Real Verse requires more complex spawning logic, so let's keep it
# simple: We'll just print a message.
if RandomChoice == 0:
print("Spawned a Barrel!")
else if RandomChoice == 1:
print("Spawned a Crate!")
else:
print("Spawned a Turret!")
# Reset the flag so it doesn't spam forever
component.ButtonPressed = false
# This function is called when the button is physically pressed by a player.
# This is the "Event" that connects to the device in the editor.
OnButtonPressedEvent := func (event: button_pressed_event) -> void:
# Find the component attached to this device
# (In a real scenario, you'd pass the component reference here)
# For this standalone example, we assume the component is active.
# Set our variable to true
# This tells the 'main' function to run the spawn logic next tick
# Note: In actual UEFN, you'd use 'SetComponent' or similar APIs.
# Here we demonstrate the concept of state change.
print("Button Pressed! Chaos incoming...")
Wait, hold up. The code above is a conceptual skeleton. Verse in UEFN is strict. You can’t just print and spawn without proper device binding. Let’s do this the correct, working way using the standard UEFN device pattern, which is much cleaner and actually works in your island.
The Real, Working Verse Component
Here is the actual, valid Verse code you can paste into a ChaosButton.verse file in UEFN. This uses the Device interface to talk to the Button device in the editor.
Walkthrough: What Just Happened?
using { ... }: These are Imports. Think of them as your backpack. You’re telling Verse, "I need the tools from the Fortnite Device library and the Unreal Engine symbols." Without this, you don’t have your tools.ChaosButton := device (...): This defines our Component. We are creating a new type of device. We say, "This device has an input (ButtonPressed) and an output (EffectTriggered)."OnAdded := func (): void: This is a Lifecycle Event. It’s like the "Start Game" signal. When the island loads, this function runs once. We use it to "listen" for button presses.ButtonPressed.Bind(...): This is the Event Binding. You’re telling Verse: "Whenever the physical button is pressed, run this anonymous function." It’s like wiring a tripwire to an explosion.SpawnChaos(): This is our custom Function. It’s a reusable block of code. We move the location up by200units (Z-axis) so the prop doesn’t clip into the button.
Try It Yourself
You’ve got the basics. Now, let’s make it more fun.
Challenge: Modify the SpawnChaos function to add a cooldown. Right now, if you spam the button, it prints "CHAOS" every single frame. That’s annoying.
Hint: You need a Variable to store the "Last Press Time."
- Add a variable to your
ChaosButtondevice definition:LastPressTime: float = 0.0 - In your
Bindfunction, check ifGetCurrentTime() - LastPressTime > 1.0. - If it’s been more than 1 second, allow the spawn and update
LastPressTime. - If not, ignore the press.
This teaches you how to use Time and Variables to control gameplay flow, just like a storm timer or a respawn delay.
Recap
- Scene Graph: Your island is a hierarchy of Entities and Components. Verse lets you build custom Components.
- Variables: Boxes that store data (like position, time, or health).
- Functions: Reusable blocks of code that perform actions (like spawning props).
- Events: Triggers that start your code (like a button press or a player entering a zone).
You’ve just written your first Verse script. It’s not a battle royale mode, but it’s a start. Now go make your friends’ islands slightly more chaotic.
References
- https://dev.epicgames.com/community/snippets/Evp/fortnite-trigger-a-barrier-with-a-time-limit
- https://dev.epicgames.com/community/snippets/YjL/fortnite-memory-sequence-device
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/discover-the-resources-waiting-you-as-a-fortnite-creator
- https://dev.epicgames.com/documentation/en-us/fortnite/create-a-platformer-with-scene-graph-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/fortnite-creative-glossary
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-fragment.verse · fragment
- 02-fragment.verse · fragment
Turn this into a guided course
Add creating 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.