Solo Queue Boss Battles: Testing Your Elimination Code with Sentry Devices
Solo Queue Boss Battles: Testing Your Elimination Code with Sentry Devices
Testing multiplayer code in UEFN is a nightmare. You write a complex elimination system, hit "Play," and realize you’re the only one there. Or worse, you’re playing against your own alt account, and the logic breaks because it expects human input. You need an AI that shoots back, dies correctly, and triggers your code without you needing to invite three friends who are all busy.
Enter the Sentry Device.
In Fortnite Creative, a Sentry is a turret. In Verse, it’s your best friend for testing. It’s a programmable enemy that fires at players and, crucially, has a built-in EliminatedEvent. This means you can test your "player kills enemy" logic in single-player mode as if you were fighting a real squad.
In this tutorial, we’re going to build a simple "Sentry Gauntlet." You’ll learn how to subscribe to a sentry’s death event, identify who killed it, and grant them a reward. It’s the perfect way to debug your combat mechanics without waiting for your lobby to fill up.
What You'll Learn
- The Problem with Single-Player Testing: Why playing alone breaks your elimination logic.
- The Sentry as a Test Dummy: How the Sentry device bridges the gap between solo dev and multiplayer testing.
- Event Subscriptions (The "Listener"): How to tell Verse, "Hey, call this function when this specific sentry dies."
- The
AgentConcept: Understanding who the "killer" is in Verse’s eyes. - Building a Reward Loop: Granting items or printing messages when a sentry falls.
How It Works
The "Ghost Player" Problem
Imagine you’re building a battle royale. Your code says: "When Player A eliminates Enemy B, give Player A 100 XP."
If you test this alone, there is no Enemy B. If you spawn a dummy bot that doesn’t have Verse code attached to its death, your code never triggers. You shoot it, it dies, but your island doesn’t know why or who did it. It just sees a dead prop.
The Sentry Solution
The Sentry device is special. It’s not just a static object; it’s an Entity with behavior. It moves, it aims, and it has an EliminatedEvent. This event is like a smoke signal. When the sentry’s health hits zero, it screams, "I am dead!"
In Verse, we don’t just watch the sentry die. We subscribe to that scream.
Analogy Time:
- The Sentry: A guard dog.
- The
EliminatedEvent: The dog barking when it gets a treat (or in this case, when it gets shot). - Your Verse Code: You standing on the porch with a notepad.
- Subscribing: Tying a string from the dog’s collar to your notepad. When the dog barks, the string pulls, and you write down what happened.
The Agent
When the sentry dies, Verse needs to know who pulled the trigger. In programming terms, the "killer" is often called the Agent. Think of the Agent as the "Hero" of the moment. If a player shoots the sentry, the Player is the Agent. If a trap kills it, the Trap is the Agent.
By subscribing to the sentry’s death event, we get access to the Agent. This lets us say, "If Player X kills Sentry Y, give Player X the Legendary Pistol."
Let's Build It
We are going to create a custom device that manages a single Sentry. When the Sentry is eliminated, it will print a message and (in a real game) grant a reward.
Step 1: The Setup
- Open UEFN and create a new Verse Device. Name it
SentryTestDevice. - In the Level Editor, place a Sentry Device.
- Place an Item Granter nearby (we’ll simulate the reward logic here).
- Connect the Sentry to your Verse Device using the On Eliminated output from the Sentry to a Custom Event input on your Verse Device? No, that’s the old way.
We’re doing it the Verse way. We’re going to attach the logic inside the Verse code, binding it to the Sentry Entity directly.
Step 2: The Verse Code
Here is the complete, annotated code for our SentryTestDevice.
# We define a new Device type. Think of this as a new "Device" in the editor.
# It will hold our logic for managing the sentry.
struct SentryTestDevice: WorldDevice =
# This is our "Sentry Entity" variable.
# We'll assign the actual Sentry Device from the level to this variable later.
SentryEntity: Entity = Invalid
# This is the "Main" function. It runs when the game starts.
OnBegin<override>()<suspends>=
# 1. Find the Sentry in the level.
# We use FindEntityByDisplayName to grab the specific Sentry we placed.
# Make sure your Sentry in the editor is named "TestSentry".
sentry_device := FindEntityByDisplayName<SentryDevice>("TestSentry")
if sentry_device != Invalid:
# 2. Get the underlying Entity from the Sentry Device.
# Devices wrap Entities. We need the Entity to access events.
SentryEntity := sentry_device.GetEntity()
# 3. SUBSCRIBE to the Elimination Event.
# This is the magic line. We tell Verse:
# "When this entity is eliminated, run the 'OnSentryDown' function."
# The `?` means the Agent might be null (e.g., if the sentry died from storm damage).
_ := SentryEntity.EliminatedEvent.Subscribe(OnSentryDown)
Print("Sentry is live. Come get some.")
else:
Print("Error: Could not find 'TestSentry' in the level!")
# This function runs ONLY when the sentry dies.
# It receives the 'Agent' (who killed it) as a parameter.
OnSentryDown(Agent: ?Agent) =
# Check if the Agent is valid (i.e., a player or object killed it, not just falling).
if Agent != Invalid:
# Get the player's name or ID to print it.
# For simplicity, we just print a message.
Print("Sentry eliminated by Agent!")
# REAL-WORLD EXAMPLE:
# If the Agent is a Player, you would now grant them a weapon.
# Player := Agent.GetPlayer()
# Player.GrantItem(ItemGranterDevice.GetGrantedItem())
else:
Print("Sentry died mysteriously (no agent).")
Walkthrough: What Just Happened?
struct SentryTestDevice: WorldDevice: We created a container for our code. This is like building a new device in the Creative tab.OnBegin: This is the "Game Start" event. It runs once when the match begins.FindEntityByDisplayName: This is how we find our Sentry. It’s like saying, "Go find the object named 'TestSentry'."SentryEntity.EliminatedEvent.Subscribe(OnSentryDown): This is the core concept.EliminatedEventis a list of "listeners" attached to the entity.Subscribeadds our functionOnSentryDownto that list.- Now, whenever the Sentry dies, Verse automatically calls
OnSentryDown.
OnSentryDown(Agent: ?Agent): This function is our "listener." It gets called with theAgent(the killer). The?is optional typing—it means "this might be nothing." If the storm killed the sentry, there’s no Agent. If a player shot it, the Agent is that player.
Try It Yourself
You’ve got the basics. Now, let’s make it useful.
Challenge:
Modify the OnSentryDown function to actually grant a weapon to the player who killed the sentry.
Hints:
- You’ll need an Item Granter device in your level. Name it
RewardGranter. - Inside
OnSentryDown, check ifAgentis a Player. You can do this by trying to get the Player component:Player := Agent.GetPlayer(). - If
Playeris valid, use theGrantItemfunction on the Player, passing in the item from yourRewardGranter. - Warning: If the sentry was killed by the Storm,
Agentwill be invalid, andGetPlayer()will crash your game. Always check forInvalidfirst!
Bonus Challenge: Make the sentry grant different weapons depending on how many times it has been eliminated. (Hint: You’ll need a variable to count eliminations, but wait... can a single sentry be eliminated multiple times? Think about respawning or using multiple sentries!)
Recap
- Sentry Devices are perfect for testing multiplayer logic in single-player because they have
EliminatedEvent. - Subscribing to an event means telling Verse to run a specific function when that event happens.
- The Agent is the entity that caused the event (usually the player who killed the sentry).
- Always check if the
AgentisInvalidbefore trying to interact with it, or your island will crash faster than a no-scope sniper.
Now go build that gauntlet. Your future multiplayer players (and your future self, debugging at 2 AM) will thank you.
References
- https://dev.epicgames.com/documentation/en-us/fortnite/team-elimination-7-testing-multiplayer-using-the-sentry-device-in-verse
- https://dev.epicgames.com/documentation/en-us/fortnite/team-elimination-game-in-verse
- https://dev.epicgames.com/documentation/en-us/fortnite/team-elimination-1-setting-up-the-level-in-verse
- https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse
- https://dev.epicgames.com/documentation/en-us/uefn/build-a-game-in-unreal-editor-for-fortnite
Verse source files
- 01-fragment.verse · fragment
Turn this into a guided course
Add team-elimination-game-7-testing-multiplayer-using-the-sentry-device-in-verse 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.