Hot, Warmer, Colder: Build a Verse-Guided Treasure Hunt
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:
- A Player: The person playing your game.
- A Goal: A hidden spot with a treasure.
- 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:
- Place a HUD Message device. Name it
ClueDisplay. - Place a Color Changing Tile or a simple Trigger Volume near the treasure.
- 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:
- Create a Verse file. Paste the simple script above.
- Place a HUD Message device in your island.
- Place a Player Spawner.
- Place a Tile that changes color when stepped on.
- In the Event Browser, find your Verse script.
- Find the
OnBeginevent. - Bind it to the
Tilestepping event. - In the Action, select your
ClueDeviceand callSetMessage.
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:
- Place a small Trigger Volume around the treasure spot.
- Name it
WinZone. - In your Verse script, listen for the
PlayerEnteredevent onWinZone. - 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
- 01-fragment.verse · fragment
- 02-fragment.verse · fragment
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.
References
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.