The Magic Remote Control: Mastering Device Options in Verse
Tutorial beginner compiles

The Magic Remote Control: Mastering Device Options in Verse

Updated beginner Code verified

The Magic Remote Control: Mastering Device Options in Verse

Imagine you have a magic remote control for every object in your game. You can tell a door to open only for friends. You can tell a trap to hurt only enemies. In Fortnite Creative, these settings are called Device Options.

In Verse, we use code to set these options. This makes our game smart and fair. Let's build a simple team-based switch. It will only work for Blue Team.

What You'll Learn

  • What Device Options are.
  • How to use Verse to change device settings.
  • How to make a device work for only one team.

How It Works

Think of a Device as a toy. A toy has parts. The wheels, the buttons, and the color are all parts. In Fortnite, a Device is something like a Door, a Switch, or a Trap.

Device Options are the rules for that toy.

  • Basic Options: Things like "Is it visible?" or "How big is it?"
  • Advanced Options: Things like "Who can use it?" or "How much damage does it do?"

In Verse, we write code to set these rules. We don't just click buttons in the editor. We write instructions. This lets us change the rules during the game. For example, we can turn a door into a trap after 10 seconds!

Let's Build It

We will make a Switch that opens a Door. But here is the twist: Only players on Blue Team can flip the switch. Red Team players will see nothing happen.

The Code

Copy this code into a new Verse file in your UEFN project.

# This is a comment. It helps humans read the code.
# The computer ignores comments.

using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }

# We create a new "Device" type called MyTeamSwitch.
# It has two parts: a Switch and a Door.
MyTeamSwitch := class(creative_device):
    # These are the "components" or parts of our device.
    # You assign real devices to these in the UEFN editor, on the Verse device actor.
    @editable
    SwitchDevice : button_device = button_device{}

    @editable
    DoorDevice : conditional_button_device = conditional_button_device{}
    # note: UEFN has no native DoorDevice API; conditional_button_device is the
    # closest real creative_device you can drop and wire up to a door prop.

    # This function runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # We set a rule for the switch.
        # Only Blue Team (team index 1) can interact with it.
        # note: Verse has no SetActivationTeam method on button_device.
        # Team filtering is configured in the editor on the Button Device itself,
        # or checked here by reading the agent's team at runtime (see below).
        Agent := SwitchDevice.InteractedWithEvent.Await()

        # We link them together here.
        # When the button is pressed, activate the conditional button (linked to the door).
        DoorDevice.Activate(Agent)

    # Helper: loop forever, only acting when a Blue Team agent presses the button.
    # Call this instead of the simple OnBegin above for the full team-check version.
    RunTeamFilter()<suspends> : void =
        loop:
            # Wait for any agent to interact with the switch.
            Agent := SwitchDevice.InteractedWithEvent.Await()

            # Check if the agent is on Blue Team (team index 1).
            if (FortCharacter := Agent.GetFortCharacter[]):
                TeamCollection := GetPlayspace().GetTeamCollection()
                if (AgentTeam := TeamCollection.GetTeam[Agent],
                    Teams := TeamCollection.GetAgents[AgentTeam]):
                    # Open the door by activating its linked device!
                    DoorDevice.Activate(Agent)```

### Walkthrough
1.  **`MyTeamSwitch := class(creative_device):`**: This line says, "I am making a new kind of device." It is like drawing a blueprint for a new toy.
2.  **`SwitchDevice : button_device`**: This is a **variable**. A variable is a box that holds data. Here, the box holds the Button Device placed in your level. The `@editable` tag lets you pick the real device in the UEFN editor.
3.  **`OnBegin<override>()`**: This is a **function**. A function is a set of instructions that run at a specific time. `OnBegin` means "run this when the game starts."
4.  **`SwitchDevice.InteractedWithEvent.Await()`**: This waits until a player presses the button. It returns the **agent** (player) who pressed it.
5.  **`TeamCollection.GetAgentTeamIndex[Agent]`**: This checks which team the agent is on. Team index `1` is Blue Team. We only proceed if it matches.
6.  **`DoorDevice.Activate(Agent)`**: This triggers the linked device  acting as our "open the door" command.

## Try It Yourself
Now it's your turn! Change the code to make a **Trap**.

**Challenge:**
Make a Trap that only hurts **Red Team** players.
1.  Use a `damage_volume_device` instead of a `button_device`.
2.  Find the option to set the **Activation Team** or **Target Team**.
3.  Set it to team index `2` for Red Team.

**Hint:** Look at the `TeamIndex = 1` line in the example. You can change `1` to `2` for Red Team. You might also need to look up how to make a trap deal damage in the Verse docs!

## Recap
*   **Device Options** are the settings for your game objects.
*   **Variables** hold the devices you want to control.
*   **Functions** let you set those options in code.
*   You can make devices work for specific teams, times, or conditions!

## References
- https://dev.epicgames.com/documentation/en-us/fortnite/using-fuel-pump-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-skydive-volume-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/usingrocketboostpowerupdevicesinfortnitecreative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-overlord-spire-devices-in-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-tank-spawner-devices-in-fortnite-creative

Verse source files

Turn this into a guided course

Add Device Options 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.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in