The "Don't Touch That" Button: Building a Custom Health Manager with Verse
Tutorial beginner

The "Don't Touch That" Button: Building a Custom Health Manager with Verse

Updated beginner

The "Don't Touch That" Button: Building a Custom Health Manager with Verse

So, you’ve got a trigger. You’ve got a player. And you want to change how much health they have when they step on it. Sounds easy, right? Just slap a "Health Powerup" device on the map and call it a day.

But what if you want to program the health? What if you want a floor that heals you slowly, or a trap that drains your HP the moment you touch it, or a "revenge zone" that only works if you’re below 50% health? That’s where standard devices fall short, and where Verse (Epic Games’ programming language for Fortnite islands) steps in.

Think of Verse as the wiring behind the walls. Standard devices are the light switches; Verse is the electrician who can wire a switch to only turn on the lights if it’s raining, or if you’re holding a specific emote. In this tutorial, we’re going to build a Custom Health Manager. We’ll use a Trigger Device to detect players, check their current health using a Variable (a container for data that changes), and then modify that health dynamically. No more static power-ups. We’re going to make the game react to the player’s state.

What You'll Learn

  • Variables: How to store and change data (like health points) during gameplay.
  • Triggers: How to detect when a player enters a specific area.
  • Logic: How to tell the game "If this happens, do that."
  • Scene Graph Basics: How devices talk to each other in the game world.

How It Works

Before we write a single line of code, let’s break down the mechanics using things you already know.

1. The Variable: Your Health Bar’s "Memory"

Imagine your health bar isn’t just a picture, but a digital counter. In programming, we call a container that holds a changing value a Variable. Think of it like a Loot Drop box. Before you open it, it’s empty (or has a default value). Once you open it, it contains something specific (a shield potion, a shotgun). The content changes based on the game state. In our case, the "box" is the player’s health, and we’re going to reach in and change what’s inside.

2. The Trigger: The "Pressure Plate"

You know how in Battle Royale, you step on a pressure plate to open a door? That’s a Trigger Device. It’s a 3D box in the world. When a player (or any agent) crosses the boundary of that box, the device fires an Event. An Event is like a Storm Timer hitting zero—it’s a signal that says, "Hey, something just happened!" Our trigger will shout, "Player entered!" and our code will listen for that shout.

3. The Scene Graph: The Family Tree of Objects

In Fortnite Creative, everything you place is part of the Scene Graph. This is just a fancy term for the hierarchy of all objects in your map. Imagine a Loadout. You have a root item (the Loadout itself), and inside it, you have weapons, consumables, and emotes. Each item knows where its parent is. In Verse, we use this hierarchy to find things. We need to find the Player Agent (the character) that just stepped in our trigger, so we can modify their health. We do this by looking up the scene graph to find who is currently inside our trigger’s volume.

4. The Logic: The "If-Then" Rule

This is the brain of the operation. In Fortnite, you might have a rule: "If I have less than 50 health, I can use this medkit." In Verse, we write this as a conditional statement. We check the player’s current health (the variable). If it’s below a certain number, we add health. If it’s above, we do nothing. Simple.

Let's Build It

We are going to build a "Desperation Healer." When a player steps into a zone, if their health is below 30, they get healed to 100. If they are above 30, they get nothing (or you can make it a damage zone, but let’s keep it positive for now).

Step 1: Set Up the Map

  1. Open UEFN (Unreal Editor for Fortnite).
  2. Place a Trigger Device (Creative -> Devices -> Triggers -> Trigger Device).
  3. Scale it up so it’s a nice big box (e.g., 500x500x200).
  4. Place a Verse Device (Creative -> Devices -> Verse -> Verse Device) right next to it.
  5. Open the Verse Device’s properties and click "Edit Code" to open the Verse editor.

Step 2: The Code

Copy and paste this into your Verse Device. Don’t worry about memorizing it yet; we’ll break it down line by line.

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

# This is our Custom Device. It's like a blueprint for our "Desperation Healer."
Desperation_Healer := class(creative_device):

    # @editable means we can change this value in the editor without rewriting code.
    # Think of this as the "Threshold" setting on a device.
    var Health_Threshold : float = 30.0
    
    # This is the function that runs when the trigger is activated.
    # It's like the "On Triggered" event in standard Creative.
    On_Trigger_Activated := func(trigger: trigger_device, agent: agent):
        # 1. Check if the agent is actually a player.
        # In Verse, 'agent' is a generic term for any character.
        # We need to cast it to a 'player_character' to access health.
        if (player_char := as<player_character>(agent)):
            
            # 2. Get the player's current health.
            # This is like checking the loot box to see what's inside.
            current_health := player_char.Get_Health()
            
            # 3. The Logic: If health is below the threshold, heal them.
            # This is the "If-Then" rule.
            if (current_health < Health_Threshold):
                # Set health to 100 (or whatever you want)
                player_char.Set_Health(100.0)
                
                # Optional: Visual feedback! Let's flash the player white for a split second.
                # This is like a "hit marker" effect.
                player_char.Set_Visual_Effect("Flash_White")
            else:
                # If they are healthy, do nothing. 
                # Or, you could add damage here: player_char.Set_Health(0.0)
                pass

# This connects our Verse code to the Trigger Device in the editor.
# It's like plugging a cable into a wall socket.
Trigger_On_Activated := func(trigger: trigger_device):
    # We need to find out *who* triggered it.
    # The trigger device gives us a list of agents currently inside it.
    agents := trigger.Get_Activated_Agents()
    
    # Loop through each agent in the list.
    # Think of this like checking every player in the lobby one by one.
    for (agent : agents):
        # Call our main function for this specific agent.
        On_Trigger_Activated(trigger, agent)

Walkthrough: What Just Happened?

  1. using { ... }: These are Imports. Think of them as the Lobby where you pick your team. You’re telling Verse, "Hey, I need access to Fortnite Devices, Characters, and Simulation tools." Without these, Verse wouldn’t know what a "player" or a "trigger" is.
  2. var Health_Threshold : float = 30.0: This is our Variable. It’s a number that can change. We set it to 30.0, but because we marked it @editable (implicitly, by placing it in the class), you can change this number in the UEFN editor without touching the code. It’s like setting the storm damage to 10 before the match starts.
  3. On_Trigger_Activated: This is a Function. A function is a reusable block of code that does a specific job. Think of it like a Grenade. You pull the pin (call the function), and it does its thing (explodes). Here, the "pin" is the trigger firing. The function takes two inputs: the trigger itself and the agent (player) who stepped in.
  4. as<player_character>(agent): This is Casting. The agent is just a generic character. It could be a bot, a player, or even a zombie. We need to be sure it’s a player so we can access their health. Casting is like checking if the loot drop is a weapon or a healing item before you try to shoot with it. If it’s not a player, the code skips the rest.
  5. Get_Health() and Set_Health(): These are Methods (functions attached to objects). Get_Health asks the player, "How much HP do you have?" Set_Health tells the player, "Here, take this much HP." It’s like using a Medkit (Set) or looking at your HUD (Get).
  6. if (current_health < Health_Threshold): This is our Conditional Logic. If the player’s health is less than 30, we execute the code inside the braces {}. If not, we ignore it. This is the core of the "Desperation Healer" mechanic.

Try It Yourself

Now that you have the basics, it’s time to get creative. The "Desperation Healer" is just the start. Here’s a challenge:

Challenge: The "High Roller" Trap

Modify the code so that instead of healing players with low health, it damages players with high health.

  • Hint 1: Change the condition in the if statement. Instead of < (less than), try > (greater than).
  • Hint 2: Instead of Set_Health(100.0), try subtracting from their current health. You can do math with variables! Example: player_char.Set_Health(current_health - 25.0)
  • Hint 3: Add a second variable called Damage_Amount so you can tweak the damage in the editor without rewriting code.

Why this matters: You’re now thinking like a game designer. You’re not just placing devices; you’re creating dynamic systems that react to the player’s state. This is the foundation of complex game modes, from battle royales to dungeon crawlers.

Recap

  • Variables are containers for data that change (like health or score).
  • Triggers detect when players enter areas and fire events.
  • Functions are reusable blocks of code that perform specific tasks.
  • Logic (if statements) lets the game make decisions based on data.
  • Verse gives you the power to connect devices and create custom gameplay mechanics that standard Creative devices can’t handle alone.

You’ve just built your first dynamic health system. Next time you see a "magic floor" in a Fortnite map, remember: there’s probably some Verse code behind it, quietly checking your health and deciding whether to heal you or hurt you. Now go make something chaotic.

References

  • https://dev.epicgames.com/community/snippets/YOJe/fortnite-simple-health-manager-use-triggers-to-modify-health
  • https://dev.epicgames.com/community/snippets/4Ayd/fortnite-health-modifier-device-pack
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/create-a-dungeon-crawler-game-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/tmnt-custom-ui-player-info-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-health-powerup-devices-in-fortnite-creative

Verse source files

Turn this into a guided course

Add fortnite-simple-health-manager-use-triggers-to-modify-health 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