Unlock the Builder’s Hotbar with Verse
Tutorial beginner

Unlock the Builder’s Hotbar with Verse

Updated beginner

Unlock the Builder's Hotbar with Verse

Welcome, young creators! Do you want to give players a special set of building tools in your Fortnite island? In Fortnite, the Build Hotbar is the row of slots where players store wood, stone, and metal. We can use Verse to give players these tools automatically. Let's learn how!

What You'll Learn

  • What a Component is in Verse.
  • How to use the Build Hotbar Component.
  • How to give items to a player using code.

How It Works

Imagine your player is a backpack. This backpack has many pockets. One pocket is for weapons. Another pocket is for traps. The Build Hotbar Component is like a special sleeve in that backpack. It holds only building materials.

In Verse, we use something called a Component. A component is like an accessory you attach to a player. It gives them new powers. The fort_inventory_build_hotbar_component is a built-in accessory. It tells the game, "Hey, this player has a build hotbar!"

When we want to give a player a tool, we don't just throw it at them. We place it in the right pocket. We use a command called AddItem. This command finds the build hotbar pocket and puts the item inside. It is like putting a toy in the correct toy box.

Let's Build It

We will create a script that gives the player wood, stone, and metal when they start. We will use a Prop Spawner. This is a device in UEFN that appears when the game starts.

Here is the code. Read the comments carefully.

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

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

    # This runs once when the island starts.
    OnBegin<override>()<suspends>: void =
        # Get the playspace so we can find players.
        Playspace := GetPlayspace()

        # Wait until at least one player is present.
        Players := Playspace.GetPlayers()
        if (Players.Length = 0):
            return

        # Find the player who started the game.
        Player := Players[0]

        # A fort_character is needed to access inventory components.
        # GetFortCharacter[] is a failable expression, so we use 'if'.
        if (FortCharacter := Player.GetFortCharacter[]):

            # We need to talk to the player's build hotbar.
            # This gets the special "sleeve" for building tools.
            # GetInventoryComponent[] is failable, so we use 'if'.
            if (BuildHotbar := FortCharacter.GetInventoryComponent[fort_inventory_build_hotbar_component]):

                # Now let's add some building materials!
                # We use AddItem to put items in the hotbar.

                # Add 100 Wood
                # note: wood_item_definition is the asset tag for the Wood resource in UEFN's Content Browser.
                BuildHotbar.AddItem(WoodItemDefinition, 100)

                # Add 100 Stone
                # note: stone_item_definition is the asset tag for the Stone resource in UEFN's Content Browser.
                BuildHotbar.AddItem(StoneItemDefinition, 100)

                # Add 100 Metal
                # note: metal_item_definition is the asset tag for the Metal resource in UEFN's Content Browser.
                BuildHotbar.AddItem(MetalItemDefinition, 100)

                Print("Player got their build tools!")

    # Item definitions are wired up in the UEFN editor as device properties.
    # Drag the Wood, Stone, and Metal asset references into these slots.
    WoodItemDefinition<public>: item_definition = item_definition{}
    StoneItemDefinition<public>: item_definition = item_definition{}
    MetalItemDefinition<public>: item_definition = item_definition{}```

### What Each Part Does

1.  **`using`**: These lines tell Verse which toolboxes to open. We need Fortnite tools and Simulation tools.
2.  **`class(creative_device)`**: This makes our script run during the game. It is like a clock that ticks.
3.  **`OnBegin`**: This is the moment the game starts. We put our code here so it runs right away.
4.  **`GetPlayers()[0]`**: This finds the first player. Think of it as picking the first kid in line.
5.  **`GetBuildHotbarComponent[]`**: This is the magic key. It unlocks the build hotbar for that player.
6.  **`AddItem`**: This is the action. It takes an item definition and a number, then puts them in the hotbar.

## Try It Yourself

You have given the player wood, stone, and metal. But what if you want to give them **Traps**?

Traps go in a different pocket. It is called the **Trap Component**.

**Challenge:**
Change the code to give the player 5 Shock Traps instead of building materials.

**Hint:**
Look at the reference docs for `fort_inventory_trap_component`. You will need to get that component instead of the build hotbar component. Then use `AddItem` with a trap item definition.

## Recap

You just learned how to talk to a player's inventory!
*   A **Component** is like an accessory that gives a player new features.
*   The **Build Hotbar Component** holds building materials.
*   **AddItem** is the command that puts items into those slots.

You are now a Verse inventor! Keep building cool islands.

## References

*   https://github.com/vz-creates/uefn
*   https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/itemization
*   https://dev.epicgames.com/documentation/en-us/fortnite/verse-api/fortnitedotcom/itemization
*   https://dev.epicgames.com/documentation/en-us/fortnite/fort-inventory-component-in-fortnite
*   https://dev.epicgames.com/documentation/en-us/fortnite/custom-inventory-and-items-overview-in-fortnite

Verse source files

Turn this into a guided course

Add fort_inventory_build_hotbar_component 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