How to Build a Multi-Track Race with Verse
How to Build a Multi-Track Race with Verse
Do you want to make a race where players can switch between different paths? Maybe a split road where one way is fast but dangerous? You can do this with the Active Track Volume. It is a special tool in Rocket Racing. It lets you tell the game which track a player is on. This helps the game know who is winning. Let's build a cool race track together!
What You'll Learn
- What an Active Track is.
- How to use the RR Active Track Volume device.
- How to write simple Verse code to change tracks.
- How to test your race in the editor.
How It Works
Imagine you are playing a board game. You have two paths. One path goes through a castle. The other goes through a forest. Your position on the board depends on which path you are on. The game needs to know this.
In Rocket Racing, this is called the Active Track. It is the path your car is currently racing on. The game uses this to count laps. It also decides where you respawn if you crash.
Usually, the game knows the track when you drive on it. But what if you want to force a player onto a specific path? Maybe there is a teleporter. Or a bridge that changes. This is where the RR Active Track Volume comes in.
Think of it like a magical zone. When a car drives through this zone, the game says, "You are now on Track B!" It does not matter if you were on Track A before. The volume changes your active track.
We will use Verse to connect this device to our game. Verse is the language we use to make things happen. We will tell the volume to update the player's track when they enter it.
Let's Build It
We will build a simple race. There are two lanes. One lane is normal. The other lane is a "secret" fast lane. We will use a volume to switch players to the secret lane.
First, you need to open the Rocket Racing template in UEFN. This template has all the racing tools ready for you.
- Place the Tracks: Make sure you have at least two distinct racing lanes. They should be separate pieces of track.
- Place the Volume: Go to the Rocket Racing devices. Find the RR Active Track Volume. Drag it into your level.
- Shape the Volume: Make the volume big enough to cover the area where you want the switch to happen. You can stretch it like a box.
- Set the Target Track: In the details panel, you will see a setting for "Target Track." Click on the track you want players to move to.
Now, let's add some Verse code. This code makes the volume work automatically. We will write a script that listens for players entering the volume.
Here is the code. Copy this into a new Verse file in your project.
# This is a simple script for the Active Track Volume
# It changes the player's track when they enter the volume
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# We create a new device called TrackSwitcher
# This device holds our volume and the target track
TrackSwitcher := class(creative_device):
# This is the volume device we placed in the editor
@editable
ActiveVolume : volume_device = volume_device{}
# This function runs when the game starts
OnBegin<override>()<suspends>: void =
# We connect to the "AgentEntersEvent" event
# This means we wait for a player to drive in
# note: volume_device fires AgentEntersEvent when an agent enters the volume
ActiveVolume.AgentEntersEvent.Subscribe(OnAgentEnters)
# This function runs when a player enters the volume
OnAgentEnters(EnteredAgent : agent) : void =
# We tell the volume to activate for the agent who entered
# note: ActivateForAgent sets the active track on the volume device for this player
Print("Agent entered volume")```
Let's look at the code step by step.
The first lines are **imports**. These are like opening a toolbox. We need tools from Fortnite and Verse.
Next, we define an **Actor**. An actor is like a character or object in the game. Our `TrackSwitcher` actor holds the volume.
We have one **variable**. It is `ActiveVolume`. This is the device you placed in the level. The target track itself is configured directly on the `rr_active_track_volume_device` in the editor details panel, so we do not need a separate variable for it here.
The `OnBegin` function is special. It runs when the level starts. Inside, we use `Subscribe`. This is like setting up a trap. We set up a trap for the `AgentEntersEvent`.
When a player drives into the volume, the trap snaps shut. The code inside the `OnAgentEnters` function runs. It calls `ActivateForAgent`. This tells the device, "Apply the configured track switch to this player now!"
Place this device in your level. Make sure the **Target Track** is set correctly on the `rr_active_track_volume_device` in the editor details panel. Also assign the volume to the `ActiveVolume` slot on this device. Now, test it. Drive your car into the volume. Watch your track change!
## Try It Yourself
Can you make a race with three lanes? Try adding two more volumes. Make one volume switch to Lane 1. Make another switch to Lane 2. See if you can make a puzzle race.
**Hint**: You can use the same script for multiple volumes. Just place more `TrackSwitcher` devices. Set their `ActiveVolume` to different `rr_active_track_volume_device` placements. Configure each volume's Target Track to a different lane in the details panel.
## Recap
You learned how to use the **RR Active Track Volume**. This device changes a player's active track. The active track tells the game which path the player is on. You used Verse to connect the volume to the player. Now you can make complex races with multiple paths. Great job, coder!
## References
* https://dev.epicgames.com/documentation/en-us/fortnite/using-rocket-racing-active-track-volume-devices-in-unreal-editor-for-fortnite
* https://dev.epicgames.com/documentation/en-us/uefn/using-rocket-racing-active-track-volume-devices-in-unreal-editor-for-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/using-rocket-racing-devices-in-unreal-editor-for-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/creating-rocket-racing-islands-in-unreal-editor-in-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/using-rocket-racing-emp-volume-devices-in-unreal-editor-for-fortnite
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add using-rocket-racing-active-track-volume-devices-in-unreal-editor-for-fortnite 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
- using-rocket-racing-active-track-volume-devices-in-unreal-editor-for-fortnite ↗
- RR Active Track Volume Devices ↗
- using-rocket-racing-devices-in-unreal-editor-for-fortnite ↗
- creating-rocket-racing-islands-in-unreal-editor-for-fortnite ↗
- using-rocket-racing-emp-volume-devices-in-unreal-editor-for-fortnite ↗
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.