Level Up Your Sentry: The Upgradeable Defense Bot
Tutorial beginner compiles

Level Up Your Sentry: The Upgradeable Defense Bot

Updated beginner Code verified

Level Up Your Sentry: The Upgradeable Defense Bot

Imagine you have a guard dog. At first, it is a puppy. It is cute, but not very strong. Later, you give it a special treat, and it grows into a big, strong protector.

In Fortnite Creative, you can do this with a Sentry. A Sentry is a robot that shoots at enemies. You can start with a weak one. Then, you can upgrade it to a super-strong one!

We will build a small arena. Inside, there will be a weak sentry. When you press a button, it turns into a tough boss sentry. This teaches you how to change things in your game using code.

What You'll Learn

  • What a Sentry device is.
  • How to hide one sentry and show another.
  • How to use a Button to trigger a change.
  • How to write simple Verse code to make it happen.

How It Works

Think of your game island like a toy box. Inside the box, you have two different robots.

Robot A is a beginner robot. It is weak. Robot B is a master robot. It is strong.

You do not want both robots on the field at the same time. That would be too easy! So, we hide Robot B. It is invisible and not active.

When a player walks up to a special Button, something magical happens.

  1. The weak Robot A stops working. It goes away.
  2. The strong Robot B wakes up. It appears.

This is called spawning and un-spawning.

  • Spawn means to appear or start.
  • Un-spawn means to disappear or stop.

We use code to watch the button. When the button is pressed, we tell the code to swap the robots. This makes the game feel exciting and challenging!

Let's Build It

First, you need to set up your devices in the Unreal Editor for Fortnite (UEFN).

  1. Place a Sentry device. Call it WeakSentry. Set its health to 500.
  2. Place another Sentry device nearby. Call it StrongSentry. Set its health to 5000.
  3. Place a Button device. Call it UpgradeButton.
  4. In the Details panel for StrongSentry, uncheck Spawn on Game Start. This hides it at the beginning.
  5. In the Details panel for WeakSentry, check Spawn on Game Start. This shows it at the beginning.

Now, let's write the Verse code. This code connects the button to the sentries.

# This is the main script for our upgrade system.
# We call this script "SentryUpgrader".

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

# This is our main class. It holds all our devices.
SentryUpgrader := class(creative_device):

    # These are our "slots" for devices.
    # We will drag devices from the editor into these slots.
    @editable
    weak_sentry: sentry_device = sentry_device{}
    @editable
    strong_sentry: sentry_device = sentry_device{}
    @editable
    upgrade_button: button_device = button_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends>: void =
        # We wait for the button to be pressed.
        # This is like waiting for a drumbeat.
        upgrade_button.InteractedWithEvent.Await()

        # When the button is pressed, we do this:

        # 1. Hide the weak sentry.
        # We send a "Despawn" signal to it.
        weak_sentry.DestroySentry()

        # 2. Show the strong sentry.
        # We send a "Spawn" signal to it.
        strong_sentry.Spawn()

        # 3. Print a message to help us debug.
        # This helps us know the code is working.
        Print("Upgrade complete! Watch out!")```

### Walkthrough

Let's look at the code line by line.

*   `@editable`
    This tag appears above each device slot. It tells UEFN to show this slot in the Details panel so you can drag a device into it.

*   `weak_sentry: sentry_device = sentry_device{}`
    This line creates a slot. It says, "I expect a Sentry device to be here." The `sentry_device{}` gives it a safe default value until you connect it in the editor.

*   `OnBegin<override>()<suspends>: void =`
    This is a special function. It runs once when the game begins. It sets up the rules.

*   `upgrade_button.InteractedWithEvent.Await()`
    This pauses the code and watches the button. It waits until a player presses it, then continues.

*   `weak_sentry.Despawn()`
    This tells the weak sentry to despawn. It disappears from the game world.

*   `strong_sentry.Spawn()`
    This tells the strong sentry to spawn. It appears and begins shooting at enemies.

## Try It Yourself

You did it! You have a working upgrade system. Now, try this challenge:

**Challenge:** Make the button reset the game.

**Hint:** Add a second button called `ResetButton`. When it is pressed, make the `StrongSentry` stop and the `WeakSentry` start again. You can copy the logic from the first button!

## Recap

You built an upgradeable sentry system. You learned that:
1.  Devices like Sentries can be hidden or shown.
2.  Code can watch for button presses.
3.  You can change the game state by starting and stopping devices.

Great job, coder! Your island is now smarter and more fun to play.

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite/using-sentry-devices-in-fortnite-creative
*   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/escape-room-9-inside-cabin-in-unreal-editor-for-fortnite
*   https://dev.epicgames.com/documentation/en-us/fortnite/escape-room-09-inside-cabin-in-unreal-editor-for-fortnite
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-sentry-devices-in-fortnite-creative

Verse source files

Turn this into a guided course

Add Upgradeable Sentry 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