Hot, Warmer, Colder: Build a Verse-Guided Treasure Hunt
Tutorial beginner

Hot, Warmer, Colder: Build a Verse-Guided Treasure Hunt

Updated beginner

Hot, Warmer, Colder: Build a Verse-Guided Treasure Hunt

Do you like treasure hunts? Do you like feeling smart when you find a secret?

In this tutorial, we will build a "Hot and Cold" game. You will use Verse code to give players hints. The hints will change as they move. It is like a digital compass.

You will learn how to make a game that talks to the player. You will also learn how to pick random goals. This makes the game fun to play again and again.

What You'll Learn

  • How to use Verse to control game messages.
  • How to make a variable change based on player distance.
  • How to use a Random Number Generator for surprise endings.
  • How to connect devices using events and actions.

How It Works

Imagine you are playing hide-and-seek. Your friend is hiding. You shout, "You're getting warmer!" That is a hint. It tells you where to go next.

In Fortnite Creative, we can do this with code. We need three things:

  1. A Player: The person playing your game.
  2. A Goal: A hidden spot with a treasure.
  3. A Guide: A Verse script that watches the player. It checks how far the player is from the goal. Then, it sends a message to the screen.

This message is called a HUD Message. HUD stands for "Heads-Up Display." It is the text you see in the corner of your screen. It does not block your view.

We will use Verse to make this smart. Verse is the programming language for Fortnite. It lets us write rules.

Here is the rule we will write:

  • If the player is far away, say "Cold."
  • If the player is closer, say "Warm."
  • If the player is very close, say "Hot!"

We will also pick a random spot for the treasure. This way, the game is different every time.

Let's Build It

First, place a Player Spawner on your island. This is where players start.

Next, place a Random Number Generator device. We will use this to pick a random treasure spot. Let's call it TreasurePicker.

Now, we need Verse code. We will write a script that runs when the game starts. It will pick a random spot. Then, it will watch the player.

Here is the code. Copy this into a new Verse file in your island.

# This is our main script. It runs the game logic.
using { /Fortnite.com/Devices }
using { /Verse.org/Sim }
using { /UnrealEngine.com/Temporary/Symbols }

# This is the TreasureHunt script.
# It controls the clues and the goal.
TreasureHunt = script():
    # This variable holds the current clue.
    # A variable is a box that can change.
    CurrentClue := "Start Searching!"

    # This function runs when the game starts.
    OnBegin<override>()<suspends>: void =
        # Pick a random number between 1 and 3.
        # This will decide which treasure spot is real.
        RandomSpot := RandInt(1, 3)
        
        # Tell the player to look for the treasure.
        # We send this message to all players.
        SendHint("Look for the treasure!")
        
        # Start watching the player's movement.
        # We do this in a loop.
        Loop():
            # Wait for the player to move.
            Wait(1.0)
            
            # Check the player's position.
            # We compare it to the random spot.
            Distance := GetDistanceToPlayer()
            
            # Decide what clue to show.
            If (Distance > 1000):
                CurrentClue = "It's very Cold."
            Else If (Distance > 500):
                CurrentClue = "Getting Warmer..."
            Else:
                CurrentClue = "You're Hot!"
            
            # Show the clue on the screen.
            SendHint(CurrentClue)

    # This helper function shows text on the screen.
    SendHint(Message: string): void =
        # This uses a built-in device to show text.
        # We assume we have a HUD Message device named 'HintDisplay'.
        # In a real setup, you would bind this to a device.
        # For this simple example, we print to the log.
        # In UEFN, you would use a HUD Message Device and bind 'Send'.
        PrintToScreen(Message)

    # This helper function checks distance.
    # In real Verse, you would get the PlayerActor and calculate vector distance.
    GetDistanceToPlayer(): float =
        # For this tutorial, we simulate a distance.
        # Real code would use GetLocation() and DistanceTo().
        return 750.0

Wait! The code above is a simplified explanation. In real UEFN, you don't write all the distance math from scratch. You use Devices.

Here is the better, easier way to build this in UEFN without complex math:

  1. Place a HUD Message device. Name it ClueDisplay.
  2. Place a Color Changing Tile or a simple Trigger Volume near the treasure.
  3. Use the Event Browser to bind events.

But since we are learning Verse, let's look at a simpler Verse pattern. We will use a Script that listens to a device.

How to connect this in UEFN:

  1. Create a Verse file. Paste the simple script above.
  2. Place a HUD Message device in your island.
  3. Place a Player Spawner.
  4. Place a Tile that changes color when stepped on.
  5. In the Event Browser, find your Verse script.
  6. Find the OnBegin event.
  7. Bind it to the Tile stepping event.
  8. In the Action, select your ClueDevice and call SetMessage.

This is the power of Verse. It connects devices. It makes them talk.

Try It Yourself

Can you make the clue change to "You Found It!" when the player gets close?

Hint:

  1. Place a small Trigger Volume around the treasure spot.
  2. Name it WinZone.
  3. In your Verse script, listen for the PlayerEntered event on WinZone.
  4. When that event fires, call ClueDevice.SetMessage("You Found It!").

You can also try changing the message color! Use ClueDevice.SetColor(White) or ClueDevice.SetColor(Red).

Recap

You built a smart treasure hunt. You used Verse to control messages. You learned that variables hold changing values. You learned that events trigger actions.

Game design is like telling a story. Your code is the narrator. It guides the player. Have fun exploring!

References

  • https://dev.epicgames.com/documentation/en-us/fortnite/hud-message-device-design-example-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/hud-message-device-design-example-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/using-hud-message-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-hud-message-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/device-design-examples-in-fortnite-creative

Get the complete code — free

You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.

Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.

Verse source files

Turn this into a guided course

Add hud-message-device-design-example-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