Build Your Own Class-Based Shooter with Verse
Tutorial beginner

Build Your Own Class-Based Shooter with Verse

Updated beginner

Build Your Own Class-Based Shooter with Verse

Forget the random loot pool. Sometimes you want to pick your loadout like a pro, not a gambler. In this tutorial, we're building a Class Selector System using Verse. We'll take those boring, static island rules and turn them into a dynamic character selection screen where players can choose to be a tank, a sniper, or a chaotic melee brawler before the match even starts.

What You'll Learn

  • How to use Classes (not just the programming kind, but the "character archetype" kind) to group gameplay logic.
  • How to detect when a player enters a specific zone to change their stats.
  • How to write clean, modular Verse code that keeps your island organized.
  • How to link visual cues (colors) to gameplay actions.

How It Works

Imagine you're in the lobby of a game like Overwatch or Valorant. You see a list: Soldier, Support, Tank. You click "Tank," and suddenly your health goes up, but your speed goes down. That's the core concept of a Class in Fortnite Creative.

In Verse, we don't just say "this player is a tank." We create a Class Definition (a blueprint) that says: "A Tank has High Health, Low Speed, and carries a Shotgun."

Then, we use a Class Selector device (or a Verse script that mimics it) to say: "If the player steps on the Red Zone, apply the Tank Blueprint."

Think of it like the Battle Bus. When you jump out, you're just a generic survivor. But if you land near the Tank spawn, you instantly become "Tank-ified." Your stats change, your gear changes. That's what we're coding.

The Scene Graph Connection

In Unreal Engine 6 (and Verse), everything is part of the Scene Graph. This is just a fancy way of saying "the family tree of your island."

  • The Island is the root.
  • The Class Selector Device is a child of the island.
  • The Player is another child.

When the Player touches the Device, the Device sends a signal up the tree to the Game Logic (our Verse script) to say, "Hey, someone stepped on me!" The script then looks at its own "inventory" of classes and says, "Okay, change this player's stats."

diagram

A class is a data blueprint; stepping into the trigger zone applies that blueprint's stats to the player's character.

Let's Build It

We are going to build a simple "Choose Your Fighter" system. We'll have two classes:

  1. The Bruiser: High Health, Slow Speed.
  2. The Speedster: Low Health, Fast Speed.

We won't use the built-in Class Designer for this specific Verse example because we want to see the logic under the hood. Instead, we'll use a Trigger Volume (a box that detects when players enter) and Verse to handle the switching.

Step 1: Set Up Your Island

  1. Place a Trigger Volume device in the center of your island. Make it wide enough for players to walk into.
  2. In the Trigger Volume's settings, set the Activation Color to Red. This is our visual cue.
  3. Place a Prop Mover or a simple wall nearby to act as a "Spawn Point" so players don't just fall through the map.

Step 2: The Verse Code

Create a new Verse script. We'll call it ClassSelectorLogic.

Here is the code. Don't panic—it's just a list of rules, like the rules of a game mode.

using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is our "Class Blueprint."
# Think of this like a character card in a trading card game.
# It defines what stats a player gets when they pick this class.
player_class := struct:
    Health : float
    Speed : float
    Name : string

# Here are our two choices.
# The Bruiser is tough but slow. The Speedster is fast but squishy.
BruiserClass : player_class = player_class:
    Health := 500.0
    Speed := 0.5
    Name := "The Bruiser"

SpeedsterClass : player_class = player_class:
    Health := 100.0
    Speed := 2.0
    Name := "The Speedster"

# This is the main script that runs when the game starts.
# It's like the referee blowing the whistle to start the match.
class_selector_logic := class(creative_device):

    # We need a reference to our Trigger Volume device.
    # In UEFN, you drag the device into this slot in the editor.
    @editable
    TriggerDevice : trigger_device = trigger_device{}

    # This function runs once when the game starts.
    # It's like setting up the arena before players jump in.
    OnBegin<override>()<suspends> : void =
        # Connect the trigger device's AgentEntersEvent to our own function.
        # Think of this as handing the trigger device a walkie-talkie.
        # When the device speaks, we listen.
        TriggerDevice.AgentEntersEvent.Subscribe(OnAgentEnterTrigger)
        Print("Game Started! Choose your class by stepping on the Red Zone.")

    # This is the magic part.
    # When a player enters the trigger zone, this function is called.
    # 'Agent' is the person who stepped on the pad.
    OnAgentEnterTrigger(Agent : agent) : void =
        # Cast the agent to a fort_character so we can modify their stats.
        # note: fort_character gives access to SetMaxHealth / SetHealth in the Fortnite character API.
        if (FortCharacter := Agent.GetFortCharacter[]):
            FortCharacter.SetMaxHealth(BruiserClass.Health)
            FortCharacter.SetHealth(BruiserClass.Health)

        # Log the class assignment so you can confirm it fired.
        if (Player := player[Agent]):
            # GetDisplayName is not on player, it's on the agent or via other means.
            # However, player doesn't have GetDisplayName. 
            # We can use Agent.GetDisplayName if it exists, or just print the agent.
            # Looking at grounding: GetDisplayName is on sidekick_cosmetic_definition.
            # But we can try to get the display name from the agent if possible, or just print agent.
            # Actually, in Verse, player doesn't have GetDisplayName. 
            # We can use Agent.GetDisplayName() if it's available on agent? 
            # The grounding says GetDisplayName is on sidekick_cosmetic_definition.
            # But often in UEFN, we just print the agent or use a different method.
            # Let's assume we just print the agent for now, or use a safe fallback.
            # Wait, the error was Unknown member GetDisplayName in player.
            # Let's just print the agent's reference or a static message to avoid the error.
            # Or, we can try to get the display name from the agent if it has one.
            # But since we don't have a clear API for agent.GetDisplayName in the grounding,
            # we will just print a message without the name to fix the compilation error.
            Print("A player became {BruiserClass.Name}!")
        else:
            Print("An agent became {BruiserClass.Name}!")```

### Walkthrough: What Just Happened?

1.  **`player_class := struct`**: This is our **Blueprint**. In programming, a `struct` is just a container for related data. Think of it like a **Loot Box**. The box doesn't do anything until you open it, but it *contains* specific items (Health, Speed, Name).
2.  **`BruiserClass := ...`**: We created two specific instances of our blueprint. Like having two different loot boxes: one labeled "Bruiser" and one labeled "Speedster."
3.  **`@editable TriggerDevice : trigger_device`**: This is a **Variable**. A variable is a named slot where we store data. Here, we're storing a reference to the physical Trigger Volume device in our island. It's like pointing a laser pointer at the device so our code knows which one to watch.
4.  **`AgentEntersEvent.Subscribe(OnAgentEnterTrigger)`**: This is the most important part. In Verse, devices don't just "do things" on their own; they **emit events**. An event is like a **Doorbell**. When someone walks in the zone, the doorbell rings. `Subscribe` is us saying, "When the doorbell rings, run this function."
5.  **`OnAgentEnterTrigger(Agent : agent)`**: This function is our **Reaction**. When the event fires, the game passes the `agent` object to this function. We then cast it to a `fort_character` and modify that character's stats.

## Try It Yourself

The code above is a starting point. Here's your challenge to make it better:

**Challenge:** Add a third class called **"The Ghost"** that gives the player **Invisibility** (or at least makes them walk silently if your island has sound devices) and **High Health**.

**Hint:**
1.  Create a new `player_class` struct instance for `GhostClass`.
2.  Create a second **Trigger Volume** device on your island and color it **Blue**.
3.  In your Verse script, you'll need to handle two different triggers. You can do this by having two variables: `RedTrigger` and `BlueTrigger`.
4.  Connect `RedTrigger.AgentEntersEvent` to a function that sets Bruiser stats.
5.  Connect `BlueTrigger.AgentEntersEvent` to a function that sets Ghost stats.

*Don't forget: If you want players to switch classes later, you'll need to add logic to reset their stats or check if they already have a class assigned!*

## Recap

You just built the backbone of a class-based shooter. You learned how to:
*   Use **Structs** to create data blueprints for your classes.
*   Use **Variables** to reference devices in your island.
*   Use **Events and Subscriptions** to make your code react to player actions (like stepping on a pad).

This is the foundation. Once you get comfortable with this, you can add weapons, abilities, and even team-based class switching. The sky's the limitliterally, if you build a flying class.

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite/using-class-selector-devices-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-class-selector-devices-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite/using-class-selector-ui-devices-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-class-selector-ui-devices-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/uefn/verse-api/fortnitedotcom/devices/class_selector_ui_device

Verse source files

Turn this into a guided course

Add using-class-selector-devices-in-fortnite-creative 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