Welcome to Verse Device Communication! In this learning path, you'll discover how to make Fortnite Creative devices talk to each other using Verse code. You'll learn to listen for player actions like button presses, run code when events happen, and chain devices together to build amazing game logicโall the skills you need to create interactive islands that respond to what players do.
Imagine you set a tripwire trap in your bedroom. The second someone walks through it โ ZAP! โ a buzzer goes off. The "someone walks through the wire" moment is called an event. An event is something that happens during the game that your code can listen for and react to.
In Fortnite Creative, devices already have built-in events. For example:
InteractedWithEvent โ it fires whenever a player walks up and presses the button.PressedEvent and ReleasedEvent โ they fire when a player presses or lets go of a certain key.Think of a podcast subscription. Once you subscribe, every new episode shows up automatically. You don't have to check manually!
Subscribing to an event works the same way. You tell Verse: "Hey, whenever this button is pressed, automatically call MY function." After that, your code runs itself every single time the event fires โ no manual checking needed.
The word for doing this in Verse is Subscribe().
The function you connect to an event is called a handler. Think of a handler like a catcher's mitt in baseball. The event throws the ball (signals that something happened), and your handler catches it and decides what to do next.
In Verse, a handler is just a regular function โ but it must follow one rule: it must accept the right inputs. For a button_device's InteractedWithEvent, the handler must accept one input called an agent. An agent is Verse's word for the player who triggered the event.
Here are the four steps you follow every time:
@editable property โ This is a special tag that lets you drag and drop your Button device into your Verse script from the UEFN editor panel. Think of it like a slot on a LEGO brick where you plug another brick in.OnBegin โ OnBegin is the function that runs the instant your island starts. It's the perfect place to set up your subscriptions, so they're ready before any player touches anything.| Word | Plain Meaning |
|---|---|
| Event | Something that happens in the game (button pressed, player arrives, timer ends) |
| Subscribe | Sign up to be notified when an event happens |
| Handler | Your function that runs when the event fires |
agent |
The player who caused the event |
@editable |
A tag that lets you link a device to your script in the UEFN editor |
The Scenario: A player walks up to a glowing button on your island and presses it. Your Verse code detects it and prints a celebration message. (Once you have the basics working, you can swap the Print for any cool game action!)
Before you code:
Here's the complete code:
# These two lines import the tools we need.
# Think of them like opening your toolbox before building.
using { /Fortnite.com/Devices } # gives us button_device and other devices
using { /Verse.org/Simulation } # gives us OnBegin and basic Verse tools
# This is our Verse device โ the "brain" we placed on the island.
button_celebration_device := class(creative_device):
# @editable means this slot shows up in the UEFN editor panel.
# Drag your Button Device from the scene into this slot!
@editable
MyButton : button_device = button_device{}
# OnBegin runs ONCE when the island starts โ perfect for setup.
OnBegin<override>()<suspends> : void =
# Subscribe = "hey, call OnButtonPressed whenever MyButton is pressed"
# OnButtonPressed is the name of our handler function below.
MyButton.InteractedWithEvent.Subscribe(OnButtonPressed)
# This is our HANDLER โ the catcher's mitt.
# It runs automatically every time the button is pressed.
# InAgent is the player who pressed the button.
OnButtonPressed(InAgent : agent) : void =
Print("๐ A player pressed the button! Amazing!")
Walkthrough โ line by line:
using { /Fortnite.com/Devices } โ Opens the toolbox that knows about button_device.@editable โ Creates a visible slot in UEFN so you can plug in the real Button device.MyButton : button_device = button_device{} โ Declares a variable named MyButton that holds a button device. The = button_device{} part is just a placeholder until you drag the real one in.OnBegin<override>()<suspends> : void = โ This runs at game start. override means we're upgrading the default version. suspends means it can wait for things.MyButton.InteractedWithEvent.Subscribe(OnButtonPressed) โ This is the magic line! It tells Verse: "Watch MyButton. When InteractedWithEvent fires, call OnButtonPressed."OnButtonPressed(InAgent : agent) : void = โ Our handler. InAgent is who pressed it. void means it doesn't hand back a value โ it just does something.Print("๐ ...") โ Shows a message in the UEFN output log. You'll see it when you test!To test it:
You're going to build an island with two Button devices. When a player presses Button A, print one message. When they press Button B, print a different message.
Steps to follow:
@editable properties โ one for each button.OnBegin, call Subscribe() on both buttons, each pointing to its own handler function.Print messages.Hint ๐: Your OnBegin should have two Subscribe lines that look like this:
MyButtonA.InteractedWithEvent.Subscribe(OnButtonAPressed)
MyButtonB.InteractedWithEvent.Subscribe(OnButtonBPressed)
Each handler still needs to accept (InAgent : agent) as its input โ don't forget that part!
Bonus Challenge โญ: Can you change the printed message to say something different depending on WHICH button was pressed? (Hint: you already are โ one handler per button!)
Check yourself: Launch your session, press Button A, then Button B. Do you see two different messages in the output log? If yes โ you did it! ๐ฅณ
An event is something that happens in the game โ like a player pressing a button. Subscribing means telling Verse: "Run my function every time that event fires." The function you connect is called a handler, and for a button_device, it must accept an agent (the player who caused the event). You set up subscriptions in OnBegin, and you use @editable to link real devices from your island into your Verse code. Now your island can truly react to players! ๐ฎ
Imagine a locked treasure room. A player walks up, presses a glowing button, and โ boom โ a weapon appears AND a door swings open! That's what you'll make today. You'll write Verse code that listens for a button press and then kicks off a whole chain of cool things.
An event is like a doorbell. When someone rings it, it tells your house "hey, something happened!" In Fortnite devices, events fire automatically when something occurs in the game โ like a player pressing a button or stepping on a trigger pad.
Your Verse code can listen for those doorbells. When one rings, your code wakes up and does something.
Subscribing means telling the game: "Hey, whenever THAT doorbell rings, call MY function."
Think of it like signing up for a pizza delivery notification. When the pizza arrives (the event), you get a text (your function runs).
The function you attach is called a handler. It's the code that "handles" what happens when the event fires.
Subscribe(YourHandlerFunction)
button_deviceA Button device is a physical glowing button you place on your island. Players walk up and press E to interact with it.
In Verse, the button has a built-in event called InteractedWithEvent. It fires every time a player presses the button.
Here's how you hook your code to it:
MyButton.InteractedWithEvent.Subscribe(OnButtonPressed)
That one line says: "When the button is pressed, run my function called OnButtonPressed."
A channel device (channel_device) is like a walkie-talkie for your devices. One device talks (transmits a signal), and any other device that's listening hears it and reacts.
Transmit() โ this is the "talk" button. It sends a signal out.ReceivedTransmitEvent โ this is the "listen" side. Other code can subscribe to this to hear the signal.You can chain devices together like dominoes! Button press โ channel transmits โ door opens. ๐
Before writing code, you need to place these devices on your island:
Tip: Use
@editablein your Verse code so you can drag-and-drop the real devices into the slots in the UEFN editor. This connects your code to the actual devices on the island!
| Word | Plain Meaning |
|---|---|
| Event | A doorbell โ something that happened in the game |
| Subscribe | Sign up to be notified when an event fires |
| Handler | The function that runs when the event fires |
| channel_device | A walkie-talkie relay that forwards signals |
| Transmit() | Sending a signal through the walkie-talkie |
| @editable | Lets you plug a real device into your code slot in the editor |
The goal: A player presses a button. An item spawns. Then a channel signal fires so other devices (like a door or timer) can react too!
In UEFN, place these devices on your island:
Then create a Verse device file called treasure_room_device and write this code:
# These lines "import" the tools we need. Think of them as opening your toolbox.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is our custom Verse device. It's like creating a new remote control.
treasure_room_device := class(creative_device):
# @editable means we can drag a real Button device into this slot in UEFN.
@editable
MyButton : button_device = button_device{}
# Drag your Item Spawner device into this slot in UEFN.
@editable
MyItemSpawner : item_spawner_device = item_spawner_device{}
# Drag your Channel device into this slot in UEFN.
@editable
MyChannel : channel_device = channel_device{}
# OnBegin runs automatically when the game starts. It's like the START button.
OnBegin<override>()<suspends> : void =
# Subscribe means: "Hey button, when someone presses you, call OnButtonPressed!"
MyButton.InteractedWithEvent.Subscribe(OnButtonPressed)
# This is the handler โ the code that runs when the button is pressed.
# InAgent is the player who pressed the button.
OnButtonPressed(InAgent : agent) : void =
# Tell the Item Spawner to drop its item right now!
MyItemSpawner.SpawnItem()
# Send a signal through the Channel device โ like pressing the walkie-talkie button!
# This lets OTHER devices react to the same button press.
MyChannel.Transmit(option{InAgent})
Print("Button pressed! Item spawned and channel signal sent! ๐")```
---
### ๐ถ Walkthrough โ What Happens Step by Step
1. **Game starts** โ `OnBegin` runs. The button is now "listening" for a press.
2. **Player walks up to the button and presses E** โ `InteractedWithEvent` fires (the doorbell rings!).
3. **`OnButtonPressed` runs** โ this is our handler.
4. **`MyItemSpawner.SpawnItem()`** tells the Item Spawner to drop the weapon immediately.
5. **`MyChannel.Transmit(InAgent)`** sends a signal through the channel device. Any other device wired to this channel (like a door or a timer) will now react too!
6. The `Print` message shows up in the log so you know it worked. โ
---
### ๐ Wiring It in UEFN
After you write the code:
1. Go to **Verse > Build Verse Code** in the menu bar.
2. Drag your `treasure_room_device` from the Content Browser into your level.
3. Click your Verse device in the level, and in the **Details panel**, drag the real Button, Item Spawner, and Channel devices into the matching `@editable` slots.
4. Hit **Launch Session** and test it! Press the button and watch the magic. ๐ช
The challenge: Create an island where the player must press two separate buttons to unlock a reward. Each button fires its own handler. When a player presses both buttons (in any order), an Item Spawner drops a legendary weapon!
Here's how to think about it:
button_device editable properties.var variable that starts as false and becomes true when pressed.true? If yes, call SpawnItem()!Devices to place on your island:
Hint โ tracking state with variables:
# A var variable can change during the game. false means "not pressed yet."
var Button1Pressed : logic = false
var Button2Pressed : logic = false
Inside your handler for Button 1, you can set it like this:
set Button1Pressed = true
Then check both with an if:
if (Button1Pressed? and Button2Pressed?):
MyItemSpawner.SpawnItem()
๐ก Remember: Use
SubscribeinOnBeginfor BOTH buttons! Each button needs its own handler function.
Bonus challenge ๐: After the item spawns, use MyChannel.Transmit(InAgent) to send a signal so a door or barrier device also opens!
Today you learned that events are like doorbells โ they fire when something happens in the game. You used Subscribe() to connect a handler function to a button press, so your code runs automatically when a player interacts. You also discovered that a channel_device acts like a walkie-talkie relay, letting one event trigger a whole chain of devices using Transmit(). Put it all together, and you can build real game logic flows โ buttons, item spawners, and signals โ all working as a team! ๐