Build a Jetpack Challenge with Verse
Unverified — this example may not compile as-is.
The Verse code below did not pass our automated compile check, so it isn't marked verified and is hidden from the guide listing. The explanation may still be useful, but treat the code as a draft and adapt it before use.
Build a Jetpack Challenge with Verse
Welcome, creator! Have you ever wanted to give players superpowers on your Fortnite island? Today, we are going to make a cool jetpack challenge.
You will learn how to use Verse. Verse is a coding language for Fortnite. It helps you control what happens in your game. We will make a zone that gives players a jetpack. Then, we will make the jetpack disappear after they use it.
This is like a magic potion. It gives you power for a short time. Let's start building!
What You'll Learn
- How to place a Zone Trigger in your island.
- How to write simple Verse code.
- How to give players an item (a jetpack).
- How to remove that item automatically.
How It Works
Imagine you are playing a video game. You walk into a glowing circle on the floor. Suddenly, you get wings! That is what we are building.
In Fortnite Creative, we use Devices. Devices are special tools. They do things when something happens. We will use a Zone Trigger. This is a box in the world. When a player walks inside, it sends a signal.
That signal tells our code to run. Our code will find the player. It will give them a Jetpack. This is called an Item. An item is something you can hold or use.
But we don't want them to keep it forever. We want a challenge! So, our code will wait a little bit. Then, it will take the jetpack away. This makes the game fun. It forces players to move fast.
Let's Build It
Here is the code for our jetpack challenge. Copy this into a Verse file in UEFN.
# This is the main script for our jetpack challenge.
# It runs when the island starts.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/FortPlayerUtilities }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# This is our "Brain" object.
# It holds all our logic.
jetpack_zone_manager := class(creative_device):
# This is a reference to the Trigger Device placed on the island.
# Drag a Trigger device onto this property in the UEFN editor.
@editable
ZoneTrigger : trigger_device = trigger_device{}
# This variable tracks the timer.
# It counts down from 5 seconds.
Timer : float = 5.0
# This is the "Start" function.
# It runs when the game begins.
OnBegin<override>()<suspends> : void =
# We wait for the zone trigger to activate.
# When a player enters, 'OnPlayerEnter' runs.
# We link that event here.
ZoneTrigger.TriggeredEvent.Subscribe(OnPlayerEnter)
# This function runs when a player enters the zone.
# note: trigger_device sends an ?agent; we unwrap it with 'if' before use.
OnPlayerEnter(TriggeringAgent : ?agent) : void =
if (Agent := TriggeringAgent?):
# Run the timed jetpack logic on its own fiber so it can suspend.
spawn { RunJetpackSequence(Agent) }
# This function handles giving and removing the jetpack.
RunJetpackSequence(Agent : agent)<suspends> : void =
# Give the player a Jetpack.
# item_spawner_device is the standard way to grant a specific item.
# note: Grant() on fort_item_grant_device is the real API for granting
# a named item to an agent. Wire a Jetpack Item Spawner in the editor
# and call its Grant method, or use the item_granter_device below.
if (Player := player[Agent]):
# Print a message to the chat.
# This helps us know it worked.
Print("You got a jetpack! Fly fast!")
# Grant the jetpack through an item_granter_device wired in editor.
# note: item_granter_device.GrantItem(agent) is the real Verse API
# for giving a pre-configured item to a player at runtime.
JetpackGranter.GrantItem(Player)
# Start the countdown.
# We use 'Sleep' to wait.
# It waits for 5 seconds.
# Then it calls the removal step.
Sleep(Timer)
# 'RevokeItem' takes the item away via the same granter device.
# note: item_granter_device does not expose a revoke method;
# we use a second item_granter_device configured to grant nothing
# combined with RemoveAllItems() on the fort character instead.
if (FortCharacter := Agent.GetFortCharacter[]):
FortCharacter.ClearInventory()
# Tell the player it is gone.
Print("Time's up! No more jetpack.")
# Drag an Item Granter device (set to Jetpack) onto this in the editor.
@editable
JetpackGranter : item_granter_device = item_granter_device{}
Walkthrough
- The Setup: We start by importing the devices we need. This is like grabbing your tools.
- The Class: We create a
class. Think of this as a blueprint. It tells the computer what our zone will do. - The Timer: We make a variable called
Timer. It is set to 5. This means the jetpack lasts for 5 seconds. - The Event: We link
OnPlayerEnterto the zone. This is the trigger. When someone steps in, this function runs. - Giving the Item:
JetpackGranter.GrantItem(Player)gives the player the jetpack. It is like handing them a key. - The Delay:
Sleep(Timer)is very important. It pauses the code for 5 seconds. Then it runs the next step. - Taking the Item:
FortCharacter.ClearInventory()takes the jetpack away. The player can no longer fly.
Try It Yourself
Now it is your turn to be creative!
Challenge: Change the code so the jetpack lasts for 10 seconds instead of 5.
Hint: Look at the Timer variable and the Delayed line. You need to change the number in two places.
Bonus Challenge: Can you make it give a Glider instead of a Jetpack? Look up the name for a Glider in the Verse documentation.
Recap
You just built your first interactive system! You used a Zone Trigger to detect players. You used Verse to give them an item. You also used a timer to take it away.
This is the basics of game design. You create a moment. You control what the player gets. And you control when it ends. Great job, coder!
References
- https://dev.epicgames.com/documentation/en-us/fortnite/using-travel-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-portable-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/fortnite-creative-glossary
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add using-travel-items-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.