The Ultimate "Turn On" Button: Mastering `Activate` in 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.
The Ultimate "Turn On" Button: Mastering Activate in Verse
You’ve placed a Conditional Button. You’ve wired it to a Prop Mover. But when you press it? Nothing. The prop stays frozen, the lights stay off, and your island feels like a broken toy. Why? Because in Verse, devices don’t just know they should work; you have to explicitly tell them to wake up.
In this tutorial, we’re going to build a "Chaos Switch" that toggles a trap on and off. We’ll learn the single most important command for making devices do stuff: Activate. By the end, you’ll stop guessing why your traps aren’t triggering and start forcing them to obey.
What You'll Learn
- The "Wake Up" Command: Why devices sit idle until told otherwise.
- The
ActivateFunction: How to call it in Verse to trigger a device. - The
AgentParameter: Who is actually pressing the button? (Hint: It’s usually the player). - Scene Graph Basics: Understanding that a device is just an object in the world that needs a "hand" to pull its lever.
How It Works
Imagine you’re playing Fortnite. You see a button on the floor. Do you press it? Only if you want to. The button itself doesn’t care if you’re standing there or in the lobby. It’s passive. It’s waiting.
In UEFN (Unreal Editor for Fortnite), devices work the same way. They are inert objects sitting in the Scene Graph (the hierarchy of all objects in your level). Even if you wire a button to a trap in the editor, Verse doesn’t always run that wire automatically. Sometimes, especially with complex logic or specific device types, you need to write code that says: "Hey, this device! Get ready! Go!"
That command is Activate.
The Activate Function
Think of Activate as the "Go" signal. It’s a function (a block of code that performs a specific action) available on most interactive devices. When you call Activate, you are telling that specific device instance to switch from "Idle" to "Active."
The Agent (The Player)
Most Activate functions in Verse require one piece of information: the Agent.
In Fortnite terms, an Agent is any player (or NPC) in the match.
- If you want everyone to trigger the trap, you might use a global activation.
- If you want only the person who pressed the button to trigger it, you pass that specific player (Agent) into the
Activatefunction.
It’s like saying: "Agent #1, you pressed the button. You are now responsible for triggering the trap."
Why Not Just Wire It?
You can wire things in the editor. But wiring is like hard-coding a path. If you want dynamic behavior—like a trap that only activates if you have a specific item, or if it’s raining, or if it’s your birthday—you need Verse. Activate is the bridge between your custom logic and the game’s built-in devices.
Let's Build It
We’re going to build a Revenge Trap.
- Place a Conditional Button.
- Place a Prop Mover (set to move a spike or explosion).
- Use Verse to make the Prop Mover only activate when the button is pressed.
Step 1: The Setup
- Open UEFN. Create a new Island or open an existing one.
- Place a Conditional Button in the world. Let's call it
RevengeButton. - Place a Prop Mover nearby. Set its "Move Type" to something dramatic, like a falling block or a spinning trap. Set its "Activation" to "Manual" or "Scripted" if available, or just leave it default for now. Let's call it
SpikeTrap. - Crucial: Do NOT wire the Button directly to the Prop Mover in the editor. We’re going to do this in code.
Step 2: The Verse Code
Create a new Verse file. This script will listen for the button press and then tell the trap to wake up.
# We need to talk to Fortnite devices, so we import the device library.
using { /Fortnite.com/Devices }
# This is our main script. It lives in the scene graph.
RevengeTrapScript := class(creative_object):
# We need references to our devices.
# Think of these as "handles" to the objects in the world.
RevengeButton: conditional_button_device = conditional_button_device{
# Replace this with the actual name of your button in the editor
name = "RevengeButton"
}
SpikeTrap: prop_mover_device = prop_mover_device{
# Replace this with the actual name of your trap in the editor
name = "SpikeTrap"
}
# This function runs when the game starts.
OnBegin<override>()<synchronized>: void =>
# 1. Listen for the button being pressed.
# When the button is pressed, run the 'ButtonPressed' function.
RevengeButton.PressedEvent += func(agent: agent):
# 2. The button was pressed! Now we activate the trap.
# We pass the 'agent' (the player who pressed it) to the Activate function.
# This tells the trap: "Hey, this player triggered you. Go!"
SpikeTrap.Activate(agent)
Walkthrough: What Just Happened?
using { /Fortnite.com/Devices }: This is like saying "I want to use the Fortnite toolkit." Without this, Verse doesn’t know what aconditional_button_deviceis.RevengeTrapScript := class(...): This creates a new "thing" in your level. It’s a container for our logic.RevengeButton: conditional_button_device: We’re creating a variable (a container for data) that holds a reference to the button. We’re telling Verse: "This variable isn't just a number; it's a specific button object."OnBegin: This function runs once when the island starts. It’s the "boot up" sequence.RevengeButton.PressedEvent += func(agent: agent):: This is the magic. We’re attaching a tiny piece of code to the button’s "Pressed" event. Whenever someone clicks the button, this code runs. Theagentis the player who clicked it.SpikeTrap.Activate(agent): This is the core lesson. We are calling theActivatefunction on ourSpikeTrap. We pass theagentalong. This tells the Prop Mover: "Activate! And by the way, this player is responsible for it."
Try It Yourself
Challenge: The trap activates for everyone if they press the button. That’s not very "revenge" if anyone can set it off.
Goal: Modify the code so that only the player who pressed the button can activate the trap. (Hint: The Activate function we used takes an agent. Does that mean the trap is now tied to that specific player? Try adding a check: if the agent who pressed the button is NOT the one standing near the trap, maybe don't activate it? Or, simpler: Use the agent parameter in Activate to see if the trap only responds to that specific player's inputs.)
Hint: In Verse, Activate(agent) often means "Activate for this specific agent." If you want to prevent others from triggering it, you might need to look at how the device handles multiple agents, or simply accept that Activate(agent) binds the action to that player. Try changing the trap to a Damage Component or Item Granter and see if only the pressing player gets the effect!
Recap
- Devices are lazy. They don’t do anything until you tell them to.
Activateis the "Go" command. It’s a function that switches a device from idle to active.Agentis the player. MostActivatefunctions take anagentparameter to specify who triggered the action.- Verse connects the dots. By using
PressedEventandActivate, you create custom, dynamic interactions that simple wiring can’t handle.
Now go make some chaos. And remember: if your trap doesn’t work, check if you forgot to Activate it!
References
- https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/devices/map_controller_device/activate-1
- https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/devices/elimination_feed_device/activate-1
- https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/devices/conditional_button_device/activate
- https://dev.epicgames.com/documentation/en-us/fortnite/verse-api/fortnitedotcom/devices/conditional_button_device/activate
- https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/devices/map_controller_device/activate
Verse source files
- 01-standalone.verse · standalone
Turn this into a guided course
Add activate-1 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.
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.