The "Find My Loot" Spell: Using Verse Tags to Hunt Entities
Tutorial beginner

The "Find My Loot" Spell: Using Verse Tags to Hunt Entities

Updated beginner

The "Find My Loot" Spell: Using Verse Tags to Hunt Entities

Imagine you're building a Fortnite island where every time a player picks up a shield potion, it explodes into confetti. Or maybe you want a trap that only triggers if it's touching a specific "danger zone" marked by a invisible tag. Doing this manually by dragging and dropping wires between fifty different props is a nightmare. You'd spend more time connecting cables than playing the game.

Enter Tags. In Verse, tags are like neon wristbands you slap on any object in your world. Instead of hunting down every single chair, table, and prop individually, you just shout, "Everyone with the #Loot tag, come here!" This tutorial teaches you how to use Verse to find all entities (objects) under your Simulation Entity that carry a specific tag. It's the difference between playing hide-and-seek blindfolded and having a radar that locks onto every player in the zone.

What You'll Learn

  • Tags: How to label objects in UEFN so Verse can find them later.
  • The Simulation Entity: The "root" of your island's hierarchy (like the Battle Bus that contains all the players and items).
  • Descendants: Understanding that "under" means everything in the family tree below a specific parent.
  • FindDescendantEntitiesWithTag: The Verse API that does the heavy lifting of searching your scene graph.

How It Works

Before we write code, let's map this to a game mechanic you already know: The Storm.

When the storm shrinks, it doesn't check every single brick in the game world to see if it's inside the circle. It checks the entities that are currently active. In UEFN, your entire island is a giant family tree called the Scene Graph. At the very top is the Simulation Entity. Think of the Simulation Entity as the Battle Bus. Everything you place in your island—props, triggers, players, traps—is a passenger on that bus.

If you want to find all the "Healing Items" in your island, you don't need to walk through every room. You just need to ask the Battle Bus: "Give me a list of all passengers who are wearing the #Healing tag."

In programming terms:

  1. Tag: A label you assign to an object in the editor (like tagging a player as "Team A").
  2. Entity: Any object in the world (a chair, a player, a trigger).
  3. Descendant: Any object that is a child, grandchild, or great-grandchild of a parent object. If you put a trap inside a room, the trap is a descendant of that room.
  4. FindDescendantEntitiesWithTag: A Verse command that looks at a parent entity (like your Simulation Entity) and returns a list of all objects below it that have a matching tag.

This is powerful because it lets you create systems that react to groups of objects rather than individual ones. Want a button that heals all players in a radius? You tag the players, find them with Verse, and boom—everyone gets healed.

Let's Build It

We're going to build a simple "Loot Goblin" system. Imagine a secret room with a button. When you press it, Verse will find all objects in the island tagged as #Loot and spawn a little particle effect (or just print a message for now) to prove it found them.

Step 1: Tag Your Objects in UEFN

  1. Open UEFN and place a few props (e.g., a chest, a shield potion, a ammo box).
  2. Select them all in the level editor.
  3. In the Details Panel, look for the Tags section.
  4. Click the + and add a tag named Loot.
  5. Note: Tags are case-sensitive. Loot is different from loot.

Step 2: The Verse Code

Create a new Verse file. We need to import the libraries that let us talk to the Scene Graph and Tags.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation/Tags }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is our main script. It runs when the game starts.
LootFinder := class(creative_device):

    # When the game starts, this function runs automatically.
    OnBegin<override>()<suspends> : void =
        # 1. Get the Simulation Entity.
        # Think of this as grabbing the "Battle Bus" of your island.
        # GetSimulationEntity[] is a failable function, so we use 'if' to safely unwrap it.
        if (SimEntity := GetSimulationEntity[]):
            # 2. Define the tag we are looking for.
            # We create a "tag type" called 'LootTag'.
            # This is like defining the color red before you can paint with it.
            LootTag := loot_tag{}

            # 3. The Magic Line!
            # We ask the Simulation Entity to find all descendants with the 'LootTag'.
            # This returns an array of entities that carry the matching tag.
            LootEntities := SimEntity.FindDescendantEntitiesWithTag(LootTag, loot_tag)

            # 4. Loop through the results.
            # 'for Entity in LootEntities' means "for every object found..."
            for (FoundEntity : LootEntities):
                # 5. Do something with the found entity.
                # For this demo, we'll just print its name to the debug log.
                # In a real game, you might make it glow, heal it, or destroy it.
                Print("Found loot item!")

loot_tag := class(tag):```

### Walkthrough: What Just Happened?

1.  **`using { ... }`**: These are like loading your inventory. We need the Scene Graph (to see objects) and Tags (to label them).
2.  **`GetSimulationEntity[]`**: This is your anchor. It finds the root of your island's hierarchy. If your island is a house, this finds the house itself, not just one room. The `[]` signals it is a failable call, so we wrap it in an `if` expression to safely unwrap the result.
3.  **`tag_Loot{}`**: In Verse, tags you define in the editor are surfaced as structs named with the `tag_` prefix followed by the tag name you set in UEFN (e.g., `tag_Loot{}`). It's the digital equivalent of a key that fits a specific lock.
4.  **`FindDescendantEntitiesWithTag(LootTag)`**: This is the core command. It searches through every object under the Simulation Entity. It's recursive, meaning it checks the Simulation Entity's children, their children, and so on. It ignores the Simulation Entity itself (you can't tag the bus, only the passengers).
5.  **`for (FoundEntity : LootEntities)`**: Verse returns an array of matching entities. The `for` loop steps through each item in that array one by one.

## Try It Yourself

You've got the basics. Now, make it useful.

**Challenge:** Instead of just printing the name of the loot, make the found objects **glow green** for 2 seconds when the script runs.

*Hint:* You'll need to use the `Entity.SetMaterialParameter()` or manipulate the material's color, but since we're beginners, try this simpler approach: Use `Entity.SetEnabled(false)` to hide them, then `Entity.SetEnabled(true)` to bring them back, or look up how to change an entity's visibility. If you want to get fancy, search for "Verse set entity color" or "Verse trigger material change."

*Need a hint on the logic?*
>!Remember, you already have the list of entities in `LootEntities`. You just need to call a function on each `FoundEntity` inside the loop. Look up `Entity.SetEnabled` or `Entity.SetHidden` in the Verse documentation.!<

## Recap

*   **Tags** are labels you assign in UEFN to group objects together.
*   The **Simulation Entity** is the root of your island's scene graph.
*   **`FindDescendantEntitiesWithTag`** searches from a parent entity down through all its children to find objects with a specific tag.
*   This allows you to create dynamic systems that react to groups of objects, not just individual props.

## References

- https://dev.epicgames.com/documentation/en-us/fortnite/creating-your-own-component-using-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/uefn/verse-starter-template-7-final-result-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/fortnite/verse-starter-07-final-result-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/transforms-in-scene-graph-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/fortnite/verse-api/versedotorg/scenegraph/finddescendantentitieswithtag

Verse source files

Turn this into a guided course

Add Get all entities that have a specific tag under the simulation entity. 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