Build Your First Secret Campfire Island
Build Your First Secret Campfire Island
Welcome to UEFN! Today, we are going to build a tiny, playable island. We will make a secret campfire that lights up when you find it. It is like a hidden treasure chest. You will place the pieces. You will write a few lines of code. Then, you will play your own creation. Let's start building!
What You'll Learn
- How to place game pieces (called Devices) in the world.
- How to connect devices using Events.
- How to make things happen with Actions.
- The basic order of building a game level.
How It Works
Building a game is like building with LEGO bricks. You have different shapes. You snap them together to make something new. In Fortnite, we use Devices. Devices are smart objects. They can do things. A trigger device waits for a player. A prop-mover device moves things. A light device glows.
We need to tell the devices how to talk to each other. We use Events. An event is like a doorbell. When someone rings it, something happens. For example, when a player touches the ground, the light turns on.
Here is the plan for our island:
- We build a small secret room.
- We put a dark campfire in the middle.
- We add a trigger on the floor.
- We write code to say: "When the player touches the floor, turn on the campfire light."
This is called a Build Step. It is the first step in making a game. You build the world first. Then you add the magic with code.
Let's Build It
We will use a simple pattern. It is called the Trigger-Action pattern. It is the most common way to start.
Step 1: Build the Room
Open UEFN. Go to the Device tab. Search for "Wall" or "Floor". Place some walls to make a small box. Make a little cave. Put a campfire prop in the center. Make sure the light is off or dim. We want it to surprise the player!
Step 2: Add the Trigger
Search for "Trigger Volume" in the Device tab. Place it on the floor inside your cave. This device watches for players. It does not do anything yet. It just waits.
Step 3: Add the Code
Now we add the magic. We need a Script. A script is a set of instructions. Think of it like a recipe.
Here is the code for our campfire. Copy this into a new script file in your project.
# This is our main script file.
# It connects the Trigger to the Light.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is our "CampfireScript".
# It is a container for our code.
CampfireScript := class(creative_device):
# This is the "Trigger" device.
# We link it in the editor later.
@editable
MyTrigger: trigger_device = trigger_device{}
# This is the "Light" device on the campfire.
# We link it in the editor later.
# note: customizable_light_device is the real UEFN light device type.
@editable
CampfireLight: customizable_light_device = customizable_light_device{}
# This function runs when the game starts.
OnBegin<override>()<suspends>:void=
# We tell the trigger to listen for players.
# "TriggeredEvent" fires when someone walks in.
MyTrigger.TriggeredEvent.Subscribe(OnPlayerEntered)
# This function runs when the event happens.
# "Agent" is the person who walked in.
OnPlayerEntered(Agent: ?agent):void=
# Turn on the campfire light!
CampfireLight.TurnOn()
# Print a message to help us debug.
Print("You found the secret campfire!")```
### How the Code Works
Let's look at the important parts.
1. **`using`**: This line brings in tools. It is like opening your toolbox. We need tools from Fortnite and Verse.
2. **`class`**: This creates a new type of object. Think of it as a custom LEGO brick. We named it `CampfireScript`.
3. **`MyTrigger`**: This is a **variable**. A variable is a box that holds a value. Here, it holds the trigger device. We will connect this box to the real device in the editor.
4. **`OnBegin`**: This is a special function. The game calls it automatically. It is like the start of a movie. We put our setup code here.
5. **`OnPlayerEntered`**: This is our **event handler**. It waits for the trigger to ring. When it does, it runs this code.
6. **`TurnOn()`**: This turns the light on. It is the action!
### Step 4: Connect the Dots
This is the most important step. The code needs to know which devices to use.
1. Click on your **Trigger Volume** device in the scene.
2. Find the **MyTrigger** property in the details panel.
3. Drag the trigger device from the scene into the **MyTrigger** box.
4. Do the same for your **Campfire Light**. Find the **CampfireLight** property. Drag the light device into it.
Now, hit **Play**. Walk into the cave. The campfire should light up! You did it!
## Try It Yourself
You made a campfire light up. That is great! Now, let's make it cooler.
**Challenge:** Make the campfire turn **OFF** when the player leaves the cave.
**Hint:**
* You need another event. Look for `EndTriggeredEvent` in the trigger device properties.
* You can add another line in your script.
* Use `TurnOff()` to turn the light off.
Can you make the light blink? Or change color? Try adding a **Color** property to the light device.
## Recap
* We built a small secret room with walls and a campfire.
* We added a **Trigger** device to watch for players.
* We wrote a **Script** to connect the trigger to the light.
* We used **Events** to make the light turn on when a player enters.
You just built your first interactive game element! You are a game creator now. Keep building and coding. The world is your LEGO box.
## References
* https://dev.epicgames.com/documentation/en-us/fortnite/campfire-device-design-example-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/uefn/box-fight-1-set-up-the-game-in-unreal-editor-for-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/working-with-the-lego-brick-editor-in-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/theme-park-lesson-plan-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/lesson-plan-theme-park-of-the-future-in-fortnite-creative
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add Build Steps 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.