The Ultimate Door Lock: How to Stop Loot Goblins With Verse
Tutorial beginner

The Ultimate Door Lock: How to Stop Loot Goblins With Verse

Updated beginner

The Ultimate Door Lock: How to Stop Loot Goblins With Verse

So you've built a sweet loot vault in Fortnite Creative. You've placed the gold, the shield potions, and the rarest of rare items. But then, a player spawns in, walks up, and—click—they're gone. Your loot is gone. Your dignity is gone.

Enter the Lock Device.

In UEFN, doors are just props until you give them authority. The Lock device is that authority. It's the bouncer at the club that checks IDs before letting you into the VIP section. In this tutorial, we're going to ditch the clunky "button next to the door" method and use Verse to create a smart lock that only opens when a specific condition is met (like holding a key item or reaching a certain score).

We'll build a "Loot Goblin Trap": a door that stays locked until a player picks up a specific key item. If they try to open it without the key, they get nothing but a solid wooden face.

What You'll Learn

  • The Lock Device: How to configure a door to ignore players by default.
  • Verse Events: How to listen for player actions (like picking up an item).
  • State Management: Using variables to track whether a player is "authorized."
  • Device Control: Sending signals from Verse to the Lock device to change its state.

How It Works

Think of the Lock Device as a magical padlock on a door. By default, in UEFN, if you place a door, anyone can open it. But if you attach a Lock device, you take the keys away from the players.

Here's the game mechanic analogy:

  • The Door: The entrance to your base.
  • The Lock Device: The keypad or biometric scanner.
  • Verse: The security guard watching the cameras.

Normally, players just walk up and press "E". With a Lock device, the security guard (Verse) has to say, "Hey, you're on the list," before the scanner (Lock) unlocks the door.

The Scene Graph Connection

In Unreal Engine 6 (and Verse), everything is part of the Scene Graph. Think of the Scene Graph as the family tree of your island.

  • Entities are the people in the family (the Door, the Button, the Lock).
  • Components are their jobs or traits (the Door has a mesh, the Lock has a state).
  • Hierarchy is who reports to whom.

When we write Verse, we aren't just moving pixels; we are reaching into the Scene Graph, grabbing the "Lock" component of our "Door" entity, and telling it to change its state from Locked to Unlocked.

Let's Build It

We are going to build a system where:

  1. A door is locked at the start.
  2. A "Key Item" (let's use a Shield Potion as the key for simplicity) is placed nearby.
  3. When a player picks up the Shield Potion, Verse detects it.
  4. Verse sends a signal to the Lock device to unlock the door.

Step 1: Set Up the Scene

  1. Place a Door asset.
  2. Place a Lock Device on that door.
    • Initial Door Position: Closed.
    • Starts Locked: Yes.
    • Hide Interaction When Locked: Yes (so players don't see "Open" when it's locked).
  3. Place a Prop (like a Shield Potion) nearby.
  4. Add an Item Granter to the prop (or just use the prop itself if it's a pickup item). For this tutorial, let's assume we use a standard pickup item. We need a way to detect when it's picked up.

Note: In Verse, detecting item pickups usually involves checking the player's inventory or using an event from an Item Granter. To keep this beginner-friendly and robust, we will use a Button Device as our "Key Pad" that gets triggered when the player interacts with a specific zone, simulating the "finding the key" moment. This is more reliable for beginners than complex inventory checks.

Revised Plan for Simplicity & Reliability:

  1. Door + Lock Device: Locked.
  2. Button Device: Placed next to the door.
  3. Verse Script: Listens for the Button being pressed. When pressed, it unlocks the Lock Device.

Step 2: The Verse Code

Here is the complete Verse script. Copy this into a new Verse file in your project.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Native }

# Define our creative_device class. This is the script that runs on the island.
my_lock_script := class(creative_device):

    # Drag your Lock Device from the World Outliner into this property slot
    # in the Details panel after compiling.
    @editable
    LockedDoor : lock_device = lock_device{}

    # Drag your Button Device from the World Outliner into this property slot
    # in the Details panel after compiling.
    @editable
    ControlButton : button_device = button_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # Make sure the door starts locked.
        LockedDoor.Lock()

        # Bind the button's InteractedWithEvent to our handler function.
        # When the button is pressed, RunUnlockLogic() will fire.
        ControlButton.InteractedWithEvent.Subscribe(RunUnlockLogic)

    # This function runs when the button is pressed.
    # button_device events pass the agent who triggered them.
    RunUnlockLogic(Agent : agent) : void =
        # Send a signal to the Lock Device to unlock.
        # Unlock() means the door is now openable.
        LockedDoor.Unlock()

        # Optional: Print a message in the debug console for us devs.
        Print("Door Unlocked! Loot is yours.")

Walkthrough: What Just Happened?

  1. @editable / LockedDoor : lock_device = lock_device{}:

    • Variable: A container that holds a value that can change. Think of it like a player's health bar. It starts at 100, but can go up or down.
    • The @editable tag exposes this variable in the UEFN Details panel so you can drag your placed Lock Device directly into the slot — that is how Verse finds the device in your level. lock_device{} is a safe default value while the class is being defined.
  2. OnBegin<override>()<suspends> : void:

    • Event: A moment in time when something happens. Like the "Game Start" signal.
    • This function runs once when the island starts. We use it to ensure the door is locked and to "listen" for the button.
  3. ControlButton.InteractedWithEvent.Subscribe(RunUnlockLogic):

    • Event Binding: Tying two things together. Like connecting a wire from a button to a light.
    • We are saying: "When ControlButton is pressed, run the RunUnlockLogic function." Subscribe registers our function so Verse calls it automatically every time the event fires.
  4. LockedDoor.Unlock():

    • Function: A set of instructions that performs an action. Like a "Heal" item.
    • Unlock() is the real lock_device API command that tells the Lock Device, "Hey, stop being locked. Let people in!" Likewise, Lock() is its counterpart used at startup to guarantee the door begins in a locked state.

Try It Yourself

Now that you have the basics, try to make it harder.

Challenge: Make the door lock again after 5 seconds.

Hint: You'll need to use a Timer Device or a Verse delay. In Verse, you can use Sleep(5.0) inside your RunUnlockLogic function to pause the script for 5 seconds, then call Lock() again. Because Sleep is a suspending call, you will need to spawn the logic as a separate task so the button stays responsive.

  • Step 1: spawn { RelockAfterDelay() } inside RunUnlockLogic.
  • Step 2: Write a new RelockAfterDelay()<suspends> : void function that calls Sleep(5.0) then LockedDoor.Lock().

If you get stuck, remember: Sleep is like the storm timer. It counts down, then does its thing.

Recap

You've just built your first Verse-powered interactive system. You learned how to:

  1. Use the Lock Device to take control away from default player interactions.
  2. Use @editable variables to reference devices placed in your scene.
  3. Use Events to trigger actions based on player input.
  4. Use Functions to send commands to devices.

Your doors are no longer just props; they're part of a game. Go forth and lock down your loot!

References

  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-lock-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/using-lock-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/using-button-device-design-examples-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/button-device-design-examples-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/conditional-button-device-design-examples-in-fortnite-creative

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

Turn this into a guided course

Add using-lock-devices-in-fortnite-creative 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