Sky High: Building a Helicopter Rescue Island
Sky High: Building a Helicopter Rescue Island
Welcome to the sky! π Have you ever wanted to rescue friends from a tall tower or race across the clouds? Today, we will build a fun helicopter rescue game. You will learn how to spawn a flying vehicle. You will also learn how to make players jump right into the pilot's seat.
It is easier than it looks. We will use simple blocks of code. You will see your helicopter appear in the sky. Let's get started!
What You'll Learn
- What a Helicopter Spawner device is.
- How to use Variables to track if a helicopter is ready.
- How to use Events to make things happen when you press a button.
- How to place a player inside the helicopter.
How It Works
Imagine your island is a big toy box. Inside, you have different toys. A Helicopter Spawner is like a magic box. When you open it, a helicopter appears!
But we want more than just a parked chopper. We want a game. Here is the plan:
- The Setup: We place a helicopter spawner on the ground.
- The Trigger: We put a button nearby.
- The Action: When you press the button, the helicopter appears.
- The Ride: When you touch the helicopter, you get inside and can fly!
In programming, we need to tell the game when to spawn the helicopter. We use something called an Event. An event is like a doorbell. When someone rings the bell (presses the button), the door opens (the helicopter spawns).
We also need to know if the helicopter is already there. We use a Variable. Think of a variable like a light switch. It can be ON or OFF. If it is OFF, the helicopter is gone. If it is ON, the helicopter is flying.
Let's Build It
We will write code to make a button spawn a helicopter. We will also make sure the player can enter it.
First, place these devices in your island editor:
- Helicopter Spawner: Place it where you want the chopper to appear.
- Button Device: Place it near the spawner.
- Trigger Device: Make it big enough to cover the helicopter.
Now, let's write the Verse code. This code connects the button to the helicopter.
# This is the main script for our rescue game.
# It connects a button device to a helicopter spawner device.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# We define our script here.
# This is like the name tag for our code.
helicopter_rescue_script := class(creative_device):
# Declare the button and helicopter spawner devices.
# Drag each device into these slots in the editor's Details panel.
@editable
RescueButton : button_device = button_device{}
@editable
RescueSpawner : vehicle_spawner_sedan_device = vehicle_spawner_sedan_device{}
# This function runs when the game starts.
# It sets up the connections.
OnBegin<override>()<suspends> : void =
# Connect the button's InteractedWithEvent to our spawn function.
# When any player presses the button, SpawnHelicopter is called.
RescueButton.InteractedWithEvent.Subscribe(SpawnHelicopter)
# This function makes the helicopter appear.
# It receives the agent (player) who pressed the button.
SpawnHelicopter(Agent : agent) : void =
# This line tells the spawner to create a vehicle.
# It uses the spawner device's placement in the editor.
RescueSpawner.RespawnVehicle()
# Print a message to the console to know it worked.
Print("Helicopter is ready for rescue!")```
### Walkthrough of the Code
Let's look at what each part does.
* `using { /Fortnite.com/Devices }`: This line brings in the tools we need. It is like grabbing your toolbox before you start building.
* `class(creative_device)`: This tells Verse that our script is a creative device β a real object that lives on your island. Every script you attach to the world must extend `creative_device`.
* `@editable`: This tag makes a variable show up as a slot in the editor's Details panel. You drag your real devices into those slots so the code can find them.
* `button_device` and `helicopter_spawner_device`: These are the real Verse types for the Button and Helicopter Spawner devices.
* `OnBegin`: This function runs once when the game starts. It is the "hello world" of setup.
* `InteractedWithEvent.Subscribe(SpawnHelicopter)`: This watches the button and calls our function every time a player presses it. `Subscribe` is how you attach a handler to an event in Verse.
* `SpawnHelicopter(Agent : agent)`: This is our custom function. `Agent` is the player who pressed the button. We do not need to use `Agent` here, but the event always sends it along.
* `RescueSpawner.SpawnVehicle()`: This is the real method on `helicopter_spawner_device` that makes the helicopter appear at the spawner's location in the editor.
## Try It Yourself
You did it! You made a helicopter appear. Now, let's make it more fun.
**Challenge:** Add a second button. When you press the second button, the helicopter should disappear.
**Hint:** Look at the Helicopter Spawner device options. Does it have a way to remove the vehicle? You can call a function on the spawner object to "Despawn" or "Remove" the vehicle. Try searching for a function like `DespawnVehicle()` or check the device's API for a removal command.
Remember, if it doesn't work, check that you dragged the correct devices into the `@editable` slots in the Details panel! The editor slot name must match the device you intend to use.
## Recap
Today you built a helicopter rescue system. You learned:
1. A **Helicopter Spawner** creates a vehicle at a specific spot.
2. **Events** let you react to player actions, like pressing a button.
3. **Functions** help you group actions, like spawning a helicopter.
Great job! Your island now has sky-high action. Keep building and flying!
## References
* https://dev.epicgames.com/documentation/en-us/fortnite/using-helicopter-spawner-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-helicopter-spawner-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/using-devices-in-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/using-biplane-spawner-devices-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-devices-in-fortnite-creative
Verse source files
- 01-device.verse Β· device
Turn this into a guided course
Add using-helicopter-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.