The Blue Bar Boss: Building a Shield Vending Machine with Verse
The Blue Bar Boss: Building a Shield Vending Machine with Verse
You’ve been there. You’re holding the high ground, you’ve got the storm at your back, and you’re low on shields. You need that blue bar to go up now. But instead of scavenging for a dropped Small Shield Potion, you want to build an island where players can buy protection like it’s a convenience store.
In this tutorial, we’re going to build a Shield Vending Machine. It’s a simple device: walk up, press a button, get shield. But behind the scenes, we’re going to use Verse to talk directly to the player’s stats. We’ll learn how to read a player’s current state and change it in real-time, which is the foundation of almost every custom game mechanic you’ll ever build.
What You'll Learn
- Variables: How to store and change data (like shield health) during the game.
- Events: How to make your code react when a player interacts with an object.
- API Calls: How to "ask" the game engine for a player’s stats and update them.
- Scene Graph Basics: Understanding where your code lives in relation to the physical objects in your map.
How It Works
In standard Fortnite, the game engine handles your shield automatically when you drink a potion. In UEFN (Unreal Editor for Fortnite), we take control. We need to ask two questions:
- What is the player’s current shield?
- How much should we add?
Think of a Variable like your inventory slot. If you have a shield potion in slot 1, that slot holds a value. If you use it, the value changes. In Verse, we create our own "slots" to track things.
However, we don’t need to create a new variable for the player’s shield. The game engine already tracks it. We just need to know how to read it and write to it. This is called an API Call (Application Programming Interface). Think of the API as a waiter. You don’t go into the kitchen to cook the food; you tell the waiter what you want, and they bring it back. Here, we’ll tell the "waiter" (the Verse API) to give the player 50 shield.
We also need an Event. An event is like a tripwire. Nothing happens until someone steps on it. In our case, the event is OnInteract. This triggers when a player presses the interaction key (usually E) near our vending machine.
Let's Build It
We are going to create a Verse Script that lives on a simple prop (like a vending machine or a crate). When a player interacts with it, the script checks if the player is alive, then adds 50 shield to them.
Step 1: The Setup
- Place a Prop in your island (e.g., a Vending Machine or a simple Box).
- Select the Prop.
- In the Details panel, go to the Verse tab.
- Click + Add Script and name it
ShieldVendingMachine. - Double-click the script to open it in the Verse editor.
Step 2: The Code
Copy and paste the following code into your script. I’ve added comments to explain what each line does, using game mechanics to keep it clear.
# This line tells Verse: "Hey, I want to use the tools that let me interact with Players."
# Think of this as equipping your loadout before a match.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Players }
# This is the main "Actor" or "Entity" your script controls.
# In the scene graph, this is the root of your code.
# It’s like the Battle Bus: everything starts and ends here.
actor ShieldVendingMachineDevice is Interactible {
# Variables are like your inventory slots.
# We define a constant here: the amount of shield to give.
# 'const' means it can't change, like the rules of the game mode.
const ShieldAmount: int = 50
# This is the Event. It's the trigger.
# It fires when a player interacts with this device.
# 'Interact' is the signal; 'Player' is the person who sent it.
event OnInteract(Player: Player) {
# Before we give shield, let's make sure the player is actually alive.
# If they're in the lobby or eliminated, we don't want to break things.
if (Player.IsAlive() == true) {
# Here is the API Call. We are asking the Player object
# to change its shield value.
# .SetShield() is the method (the action).
# We pass (ShieldAmount) as the argument (the data).
Player.SetShield(ShieldAmount)
# Optional: Let's give the player a tiny bit of health too,
# just to make it feel like a "heal station."
Player.SetHealth(10)
}
}
}
Walkthrough: What Just Happened?
using { ... }: These lines are your Loadout. You can’t use a shotgun if you didn’t pick it up at the start. These lines tell Verse, "I need access to Player logic and Device logic."actor ... is Interactible: This defines your Entity. In the Scene Graph, this Actor is a node. By saying itis Interactible, we’re telling the engine, "This object can be clicked by players." It’s like tagging a prop as a "Trigger" in the old Unreal Editor.const ShieldAmount: int = 50: This is a Constant. It’s a variable that never changes. Think of it like the max health cap. You set it once, and it stays that way for the whole game. If you wanted to make a "Super Shield" machine, you’d just change this number to 100.event OnInteract(Player: Player): This is the Trigger. It waits for a signal. When a player stands near the prop and presses E, the game engine sends a message: "Hey, Player X interacted with this Device."Player.SetShield(ShieldAmount): This is the Action. We are directly manipulating the player’s stats. It’s like using a Heal Trap, but instead of healing over time, we’re giving a flat boost instantly.
Try It Yourself
The vending machine works, but it’s a bit too generous. Everyone gets 50 shield, even if they’re already full. Let’s make it smarter.
Challenge: Modify the script so that it only gives shield if the player’s current shield is less than 50. If they already have 50 or more, do nothing (or maybe print a message if you’re feeling fancy).
Hint: You’ll need to read the player’s current shield before you set it. Look for a method on the Player object that returns a value, like GetShield(). You’ll need to store that value in a temporary variable to compare it.
Recap
You’ve just built your first interactive Verse script. You learned how to:
- Use Actors to tie code to physical objects in your map.
- Use Events to react to player actions.
- Use API Calls to read and write player stats directly.
This is the building block for everything else. From custom health packs to dynamic storm timers, it all starts with knowing how to talk to the player’s stats. Now go make that blue bar glow.
References
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-shield-consumables-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-consumables-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-consumables-gallery-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-shield-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-healing-consumables-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
- 01-fragment.verse · fragment
- 02-fragment.verse · fragment
Turn this into a guided course
Add using-shield-consumables-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.
References
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.