The Invisible Tripwire: Building a "One-Shot" Trap with Verse
Tutorial beginner compiles

The Invisible Tripwire: Building a "One-Shot" Trap with Verse

Updated beginner Code verified

The Invisible Tripwire: Building a "One-Shot" Trap with Verse

So, you want to build a trap that only goes off once? Or maybe a secret door that opens just for the first person to find it? In standard Creative mode, you have to manually toggle devices or use complex logic gates to prevent a trigger from firing twice. It's tedious. It's prone to error. And frankly, it's boring.

In Verse, we treat triggers like consumable items. Think of a grenade: you pull the pin, it explodes, and now it's gone. You can't pull the pin on a grenade that has already exploded. That's the core concept we're teaching today: State Management. We're going to build a "One-Shot" trap. When a player steps on it, it triggers an event (like a drop of loot or a spike of damage) and then permanently disables itself so it never triggers again. No more accidental double-drops. No more infinite loops of chaos (unless you want them, but that's a tutorial for another day).

What You'll Learn

  • Variables: How to store a "yes/no" status (like a health bar that goes from 100 to 0).
  • Conditional Logic: The if statement, which acts like a bouncer checking IDs at the club.
  • The Scene Graph: Understanding how your Verse script "owns" the devices in your island.
  • Event Binding: Connecting a physical trigger in the editor to your code.

How It Works

To understand Verse, you have to stop thinking about "devices talking to devices" and start thinking about "code controlling devices."

1. The Scene Graph: Your Island's Family Tree

Imagine your island is a family. The World is the grandparent. The Island is the parent. The Triggers, Prop Movers, and Item Granters are the kids. In Verse, you don't just grab a device out of thin air. You have to reach into the family tree and grab the specific kid you want. This structure is called the Scene Graph. If you try to talk to a device that isn't in your script's family tree, the game throws a fit (an error).

2. Variables: The Inventory Slot

A variable is just a labeled box where you store information. In Fortnite, think of a variable like an inventory slot that holds a single item. If that slot holds a "Shield Potion," you know you're healed. If it holds a "Grenade," you're about to blow something up.

We need a variable to track if our trap has already been used. Let's call it IsUsed.

  • If IsUsed is False, the trap is ready.
  • If IsUsed is True, the trap is empty.

3. The Bouncer (Conditional Logic)

When a player steps on the trigger, the game asks: "Has this trap been used?" This is an if statement. It's like a bouncer at a VIP club.

  • The Question: "Is IsUsed equal to False?"
  • If Yes: The bouncer lets you in. The trap fires (damage/loot), and then the bouncer locks the door (IsUsed becomes True).
  • If No: The bouncer says, "Sorry, this trap is spent." Nothing happens.

4. Events: The Trigger Pull

In Verse, devices don't just "do" things on their own. They send out Events. An event is like a smoke signal. When you step on the trigger, it sends a smoke signal saying, "I was stepped on!" Your Verse script is standing there watching for that specific smoke signal. When it sees it, it runs the logic we just described.

Let's Build It

We are building a Secret Loot Box that appears when you step on a pressure plate. Once you loot it, the plate breaks (or just stops working), and the loot box vanishes forever.

Step 1: Set Up the Devices

  1. Place a Trigger in your map. Rename it LootTrigger.
  2. In the Trigger's settings:
    • Visible In Game: False (We don't want players seeing the trigger volume).
    • Triggered By Player: True (We want players to step on it).
    • Trigger VFX/SFX: False (Keep it clean).
  3. Place an Item Granter somewhere nearby. Rename it SecretLoot.
    • Set it to Enable On Game Start: False.
    • Set it to Enable When Receiving From: Channel 1.
  4. Place a Prop Mover (or just use the Item Granter's visibility if you prefer, but let's use a Prop Mover to hide the loot box). Rename it LootBoxProp.
    • Set it to Visible In Game: False.
    • Set it to Enable When Receiving From: Channel 1.

Step 2: The Verse Code

Create a new Verse file in your project. Let's call it OneShotLoot.verse.

Here is the code. Don't panic—we'll break it down line by line.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# We are creating a "Device" which is a container for our logic.
# Think of this as the "Island" object that holds our specific trap.
one_shot_trap := class(creative_device):

    # This is our "Family Tree" reference.
    # We are telling Verse: "Hey, inside this Island, there is a device
    # named 'LootTrigger'. Connect it to this script."
    # Drag your trigger device onto this property in the UEFN details panel.
    @editable
    LootTrigger : trigger_device = trigger_device{}

    # We also grab the Item Granter and the Prop Mover.
    # If these aren't connected in the details panel,
    # Verse will complain. Accuracy is key!
    @editable
    LootBox : item_granter_device = item_granter_device{}

    @editable
    LootBoxProp : prop_mover_device = prop_mover_device{}

    # This is our "Inventory Slot" (Variable).
    # It starts as false, meaning the trap is READY.
    # <var> marks this as mutable so we can change it later.
    var IsTrapUsed : logic = false

    # OnBegin runs automatically when the game starts.
    # This is where we bind our event listener to the trigger.
    OnBegin<override>()<suspends> : void =
        # This is the "Event Handler."
        # It says: "Whenever LootTrigger sends a 'TriggeredEvent' signal,
        # run the function below."
        LootTrigger.TriggeredEvent.Subscribe(OnLootTriggerTriggered)

    # This function runs every time the trigger is activated.
    # It receives the agent (player) who stepped on the trigger.
    OnLootTriggerTriggered(TriggeredAgent : ?agent) : void =
        # THE BOUNCER LOGIC
        # Check if the trap has already been used.
        if (IsTrapUsed = false):
            # It hasn't been used! Let's activate the trap.

            # 1. Enable the Item Granter (gives the loot)
            LootBox.Enable()

            # 2. Enable the Prop Mover (shows the loot box)
            LootBoxProp.Enable()

            # 3. IMPORTANT: Mark the trap as used so it can't happen again.
            set IsTrapUsed = true

            # Optional: Disable the trigger itself so it doesn't send signals anymore.
            # This is like unplugging the smoke signal.
            LootTrigger.Disable()
        # If IsTrapUsed is already true, the if block simply doesn't run.
        # The trap was already used — do nothing.
        # You could enable a separate "Already Looted" device here if you wanted.

Walkthrough: What Just Happened?

  1. one_shot_trap := class(creative_device): This defines our script. It's like drawing the blueprint for a new type of device. It inherits from creative_device, which means it can interact with other devices and runs on your island automatically.

  2. var IsTrapUsed : logic = false Here is our variable. We initialized it to false. In Verse, var marks a field as mutable so you can change it later with set. It's like putting a "Ready" sticker on the trap.

  3. @editable LootTrigger : trigger_device = trigger_device{} This is the Scene Graph magic. The @editable attribute exposes this field in the UEFN details panel so you can drag your actual LootTrigger device onto it. If you forget to connect it in the panel, Verse will use the empty default and nothing will work. Connections must be made in the editor.

  4. OnBegin<override>()<suspends> : void This is the entry point that runs when the game starts. We use it to call Subscribe, which registers our handler function so it watches for the trigger event going forward.

  5. LootTrigger.TriggeredEvent.Subscribe(OnLootTriggerTriggered) This binds the event. It listens for the specific moment the player steps on the trigger. When that happens, OnLootTriggerTriggered runs automatically.

  6. if (IsTrapUsed = false): This is the conditional check. It asks: "Is the trap ready?"

    • If Yes: It runs the code inside the if block.
    • If No: It skips the block and does nothing.
  7. set IsTrapUsed = true This updates the variable. In Verse, set is required to reassign a var field. We changed the "Ready" sticker to a "Used" sticker. Now, the next time someone steps on the trigger, the if check will fail, and the trap will stay dormant.

Try It Yourself

You've built a one-shot trap. Now, let's make it more interesting.

Challenge: Modify the code so that if the trap has already been used (IsTrapUsed = true), it plays a sound effect or displays a message saying "Already Looted!" instead of doing nothing.

Hint: Add an @editable field for an audio_player_device or a hud_message_device at the top of the class, connect it in the editor, then call .Play() or .Show() inside an else block after your if. Remember, you need to declare that device as an @editable field first!

Recap

  • Variables are like inventory slots that store state (e.g., IsTrapUsed). Mark them var so they can be changed, and use set to update them.
  • The Scene Graph is the family tree of your island; use @editable fields to connect specific devices from the editor into your script.
  • Events (like TriggeredEvent.Subscribe) let your code react to player actions.
  • Conditionals (if statements) let you decide what happens based on the current state of your variables.

By combining these, you move beyond simple device chaining and start building dynamic, responsive games where the world changes based on player actions. Now go forth and break some traps (only once, please).

References

  • https://dev.epicgames.com/documentation/en-us/fortnite/party-game-3-sequencer-cannonball-animations-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/dungeon-crawler-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/dungeon-crawler-gameplay-example-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/uefn/party-game-3-animate-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/fortnite/parkour-elimination-4-elimination-arena-in-unreal-editor-for-fortnite

Verse source files

Turn this into a guided course

Add Triggers 1-5 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