
Magic Layers: Build a World That Changes!
Magic Layers: Build a World That Changes!
Do you want to build a Fortnite island that changes from day to night? Or maybe one where a bridge appears only when you step on a switch?
You can do this with Data Layers. Think of them like magic stickers. You can stick them on your world, peel them off, or swap them out instantly.
In this tutorial, you will learn how to use Data Layers to make a secret room appear.
What You'll Learn
- What a Data Layer is.
- How to put objects into different layers.
- How to hide and show layers using Verse code.
- How to create a "secret door" effect.
How It Works
Imagine your Fortnite island is a giant stack of clear plastic sheets. This is called the Scene Graph.
Each sheet is a Layer.
- Layer 1 has the grass and trees.
- Layer 2 has the house walls.
- Layer 3 has the secret treasure chest.
When you play the game, you can turn these sheets on or off. If you turn off Layer 2, the walls disappear. If you turn on Layer 3, the treasure appears!
This is perfect for games. You can hide traps until a player gets close. You can change seasons by swapping a "Winter" layer for a "Summer" layer.
Let's Build It
We will build a simple room. There will be a door. When you touch the door, the walls will vanish, and a treasure chest will appear!
Step 1: Set Up Your Layers
- Open your island in UEFN.
- Look for the World Partition panel on the right.
- Click Add Data Layer. Name it
Walls. - Click Add Data Layer again. Name it
Treasure. - Place a Prop-Mover (this is our door) in the center.
- Place some Props (boxes or walls) around it. Put these in the
Wallslayer. - Place a Treasure Chest prop. Put this in the
Treasurelayer.
Step 2: Write the Verse Code
Now, we need code to make the magic happen. We will use a Trigger. When a player walks into it, the code runs.
Copy this code into a new Verse file in your project.
# Import the tools we need
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is our main device
secret_door_device := class(creative_device):
# This is the trigger pad — wire this in the UEFN Properties panel
@editable
TriggerPad : trigger_device = trigger_device{}
# This is the list of prop devices for the Walls layer.
# Add every wall prop_manipulator device here in the Properties panel.
@editable
WallProps : []prop_manipulator_device = array{}
# This is the list of prop devices for the Treasure layer.
# Add every treasure prop_manipulator device here in the Properties panel.
@editable
TreasureProps : []prop_manipulator_device = array{}
# This runs when the game starts
OnBegin<override>()<suspends> : void =
# Wait for a player to touch the pad, then run on_player_touch
TriggerPad.TriggeredEvent.Await()
on_player_touch()
# This function runs when someone touches the pad
on_player_touch() : void =
# 1. Hide the 'Walls' layer
# This makes the walls disappear
for (Wall : WallProps):
Wall.Disable()
# 2. Show the 'Treasure' layer
# This makes the chest appear
for (Chest : TreasureProps):
Chest.Enable()
# Optional: Play a sound or effect here!
Print("Secret room opened!")```
### How the Code Works
* **`class(creative_device)`**: This tells Verse this is a special device for your island.
* **`TriggerPad`**: This is the object in your level that detects players. The `@editable` tag lets you wire it up in the UEFN Properties panel.
* **`TriggeredEvent.Await()`**: This is an **Event**. It fires when a player touches the trigger. Think of it like a light switch clicking on.
* **`prop_manipulator_device`**: This is the real UEFN device that can show or hide a single prop. You add one to the level for each wall or treasure prop, then wire them into the `@editable` arrays in the Properties panel.
* **`.Hide()` and `.Show()`**: These are the magic commands on `prop_manipulator_device`.
* `.Hide()` makes the prop invisible and solid objects non-collidable.
* `.Show()` makes the prop reappear.
### Step 3: Connect It in UEFN
1. Place the **secret_door_device** Creative Device in your level.
2. Place a **Prop Manipulator** device next to every wall prop and every treasure prop in your level.
3. In the **Properties** panel for your secret_door_device, find the `TriggerPad` slot and drag your Trigger device into it.
4. Add each wall Prop Manipulator into the `WallProps` array, and each treasure Prop Manipulator into the `TreasureProps` array.
5. Test your island! Walk into the trigger. Do the walls disappear? Does the chest appear?
## Try It Yourself
You did it! You made a secret room. Now, try this challenge:
**Challenge:** Add a third layer called `Obstacles`. Put some spikes in this layer. Make the spikes appear *only* when the walls disappear.
**Hint:** You need to add a new `@editable` array called `ObstacleProps` for your spike Prop Manipulator devices. Then, add another `for` loop in the `on_player_touch` function that calls `.Show()` on each one.
## Recap
* **Data Layers** are like clear sheets in a stack.
* You can hide or show props with Verse code using `prop_manipulator_device`.
* Use `.Hide()` and `.Show()` to toggle visibility.
* This makes your island feel alive and magical!
## References
* https://dev.epicgames.com/documentation/en-us/uefn/UE/building-virtual-worlds/world-partition/world-partition-data-layers
* https://dev.epicgames.com/documentation/en-us/uefn/UE/ue-reference-environments-and-landscapes-in-unreal-editor-for-fortnite
* https://dev.epicgames.com/documentation/en-us/fortnite/uefn-vs-ue-in-unreal-editor-for-fortnite
* https://dev.epicgames.com/documentation/en-us/uefn/UE/building-virtual-worlds/world-partition/world-partition-hlods
* https://dev.epicgames.com/documentation/en-us/fortnite/streaming-and-hlods-in-unreal-editor-for-fortnite
Verse source files
- 01-device.verse · device
Check your understanding
Test yourself with an interactive quiz and track your progress + earn XP — free for members.
Turn this into a guided course
Add world-partition-data-layers 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.