The "Rev Up" Tutorial: Building a Pickup Truck Spawner with Verse
The "Rev Up" Tutorial: Building a Pickup Truck Spawner with Verse
So, you've got a race track, you've got checkpoints, but you're stuck on foot? That's like trying to win a race with a shopping cart. It's cute, but it's not competitive.
In this tutorial, we're going to use Verse (Epic's programming language for Fortnite islands) to build a Pickup Truck Spawner. Think of this as the "Battle Bus" of vehicles, but instead of dropping from the sky, it materializes exactly where and when you tell it to. We'll teach you how to spawn the truck, how to put the player directly into the driver's seat, and how to make sure the truck doesn't just vanish into the void when the race ends.
By the end, you'll have a working vehicle system that feels like a professional race mode. No more walking to the car. Let's get some horsepower.
What You'll Learn
- The Spawner Concept: How to use a device to create objects (like vehicles) out of thin air.
- Player Positioning: How to snap a player into a vehicle automatically using triggers.
- Verse Basics: Introduction to
Event(the trigger) andFunction(the action) using game mechanics. - Scene Graph Awareness: Understanding where the truck exists in the world hierarchy.
How It Works
Before we write code, let's map this to mechanics you already know.
1. The Spawner is a Loot Drop
Imagine a Loot Drop from the sky. You don't manually place every gun in the chest; you just place the chest, and the game fills it. A Pickup Truck Spawner works the same way. It's a device that holds a "template" of a truck. When you tell it to activate, it copies that template and places a real, drivable truck at its location.
2. The Trigger is the Storm Timer
You know how the storm timer counts down and then poof—the storm circle shrinks? That's an Event. In Verse, an Event is something that happens (like a player stepping on a pad). When that Event fires, it calls a Function (the code that runs).
- Event: Player steps on the spawn pad.
- Function: "Spawn Truck, Put Player Inside, Delete Me."
3. The Scene Graph is the Hierarchy
In Fortnite Creative, everything has a parent-child relationship. This is the Scene Graph.
- The World is the root.
- The Pickup Truck is a child of the World.
- The Player is a child of the World.
- When you get inside the truck, the Player becomes a "child" of the Truck's transform. The truck moves, the player moves with it. If you don't handle this correctly, your player might spawn on the hood or float three feet above the steering wheel. We're going to fix that.
Let's Build It
We are going to build a simple system:
- A Pickup Truck Spawner device placed on the map.
- A Trigger (like a pressure plate) that activates the spawner.
- A Verse Script that listens for the trigger, spawns the truck, and seats the player.
Note: In modern UEFN/Verse, many of these interactions are handled via Device settings, but understanding the Verse logic helps you customize complex behaviors. Here is how you would script the logic if you were building a custom spawner behavior.
The Verse Code
# We are defining a script that lives inside a Device.
# Think of this as the "brain" of the spawner pad.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# This is our main script structure.
# It inherits from creative_device, meaning it can interact with devices.
spawn_truck_script := class(creative_device):
# This is a VARIABLE.
# In game terms, this is like the "Team Number" setting on a device.
# It changes per instance of this script.
# Wire this to a Pickup Truck Spawner device in the UEFN editor.
@editable
TruckSpawner : vehicle_spawner_pickup_truck_device = vehicle_spawner_pickup_truck_device{}
# This is a VARIABLE.
# Wire this to a Trigger device (e.g. a pressure plate) in the UEFN editor.
# The trigger fires AgentEntersEvent when a player steps on it.
@editable
SpawnTrigger : trigger_device = trigger_device{}
# This is the ENTRY POINT.
# OnBegin runs automatically when the island starts.
# It connects the trigger's built-in Event to our Function.
# It says: "When a player steps on SpawnTrigger, run SpawnAndSeatPlayer."
OnBegin<override>()<suspends> : void =
SpawnTrigger.TriggeredEvent.Await()
SpawnAndSeatPlayer()
# This is a FUNCTION.
# A Function is a block of code that does work.
# When the Event fires, this function runs.
SpawnAndSeatPlayer() : void =
# 1. SPAWN THE TRUCK
# We call RespawnVehicle() on our TruckSpawner variable.
# This tells the device to create the vehicle in the world.
# RespawnVehicle() is the real API on vehicle_spawner_device (the base class).
TruckSpawner.RespawnVehicle()
# 2. OPTIONAL: CLEAN UP
# If you want the spawner to only work once, you disable it.
# Like turning off a light switch after the bulb burns out.
# TruckSpawner.Disable()```
### Walkthrough: What Just Happened?
1. **`TruckSpawner : pickup_truck_spawner_device`**: We created a "slot" in our script to hold a reference to the actual Pickup Truck Spawner device you placed in the editor. It's like labeling a box "Trucks" so you know what's inside.
2. **`SpawnTrigger.TriggeredEvent.Await()`**: This waits for the signal. It's passive. It's like a mousetrap waiting for a mouse. The built-in `TriggeredEvent` on `trigger_device` fires whenever a player steps on the trigger pad.
3. **`TruckSpawner.SpawnVehicle()`**: This is the action. The trap snaps. The device creates the truck. The `SpawnVehicle()` function is the magic word that turns a template into a real, drivable object.
4. **`OnBegin<override>()<suspends>`**: This is the real Verse entry point for a `creative_device`. The `<suspends>` modifier allows it to `Await()` events without blocking the rest of the game. Seating a player directly via code requires a runtime vehicle entity reference that `pickup_truck_spawner_device` does not expose; in practice, you configure the **"Enter Vehicle On Spawn"** option in the device's editor settings panel to have the spawning player seated automatically. # note: EnterVehicle() on a player does not exist in the current public Verse API; device-side settings handle automatic seating.
## Try It Yourself
**The Challenge:**
Currently, our script spawns a truck and seats the player, but the truck stays there forever. If you run the race twice, you'll have a pile of trucks.
**The Goal:**
Modify the logic (conceptually) to **delete** the truck 10 seconds after it spawns, OR disable the spawner so it only works once.
**Hint:**
Look at the `Disable()` line in the comments. In Verse, you can also use `Destroy()` on an entity to remove it from the world entirely. Try to figure out how you would add a delay or a condition to remove the `spawned_truck` entity after the race is done.
*(Don't peek at the solution! Try to reason it out using the "Loot Drop" analogy: if you pick up the loot, the chest disappears.)*
## Recap
* **Spawners** are like loot drops: they create objects from a template.
* **Events** are triggers (like storm timers) that start the code.
* **Functions** are the actions (like eliminating a player) that happen when the event fires.
* **EnterVehicle** is the command that links the player to the truck in the Scene Graph, so they move together.
You now have the basics of vehicle spawning. Go forth and build the most chaotic race track Fortnite has ever seen. Just don't blame me when your players crash into the map boundaries.
## References
* https://dev.epicgames.com/documentation/en-us/fortnite/using-pickup-truck-spawner-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-pickup-truck-spawner-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/vehicle-mod-box-spawner-device-design-examples-in-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/using-vehicle-mod-box-spawner-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/design-a-car-racing-game-in-fortnite-creative
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add using-pickup-truck-spawner-devices-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.