Verse Library verse

01 Device

Searches the scene and returns a list of all entities marked with a specific tag.

verse-library/get-all-entities-that-have-a-specific-tag-under-the-simulation-entity/01-device.verse

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.

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in