---
title: "Build Your First Game — Learning Path"
date: "2026-06-21"
category: "education"
excerpt: "Welcome to your UEFN adventure! In this learning path, you'll discover how to build a complete playable island in Fortnite using Verse, a powerful scripting language. From spawning players to tracking scores and deciding who wins, you'll learn the core skills that make games fun and fair—all by writing code that brings your creative vision to life!"
level: "grade4-6"
estimated_minutes: 240
author: "Verse Cortex"
status: "published"
---

# Build Your First Game

Welcome to your UEFN adventure! In this learning path, you'll discover how to build a complete playable island in Fortnite using Verse, a powerful scripting language. From spawning players to tracking scores and deciding who wins, you'll learn the core skills that make games fun and fair—all by writing code that brings your creative vision to life!

**Reading level:** grade4-6  ·  **Estimated time:** 240 min  ·  **Lessons:** 6

## What You'll Learn

- Write Verse code to detect when players join and leave your island
- Build a score-tracking system that updates during gameplay
- Create round logic that resets data between games and tracks player progress
- Set up win conditions using elimination counts and the End Game Device
- Design and playtest a complete, working island with spawning, scoring, and victory conditions

---

## Lesson 1: Introduction to Verse and Creating Your First Device

**Objectives:**

- Explain what Verse is and why it's useful for making Fortnite islands
- Set up a new project in Unreal Editor for Fortnite (UEFN)
- Create a new Verse device file and give it a name
- Compile your code and drag your device into your island to play-test it

### 🎮 What Is Verse?

Imagine you're building a Fortnite island with devices — things like triggers, timers, and item granters. Devices are awesome! But they only connect in certain ways. It's like a box of LEGO bricks where every brick has a fixed shape. You can build a lot, but some cool ideas just don't fit.

**Verse** is Epic Games' special programming language for Fortnite islands (and will also power Unreal Engine 6 — the future of game-making!). Think of Verse as a magic set of LEGO instructions that lets you **invent your own brick shapes**. If no device can do what you want, you write Verse code to make it happen yourself.

> 💡 **Programming language** — a way to give the computer a list of instructions it can follow, like a recipe for a game.

---

### 🛠️ What Is UEFN?

**UEFN** stands for **Unreal Editor for Fortnite**. It's the free app you use to build custom Fortnite islands on your computer. Think of it as your game-building workshop. You place devices, design the map, and write Verse code — all in one place.

---

### 🤔 Why Learn Verse?

Here's a quick list of super-powers Verse gives you:

- **Complex interactions** — Make a player's score change the color of a prop in real time.
- **Precise timing** — Spawn enemies at exactly the right moment.
- **Brand-new rules** — Invent a game mode that no device combo could ever build.
- **Dynamic play** — React to what a player does *right now* during the game.

---

### 📄 What Is a Verse Device?

A **Verse device** is a special object you make with code. Once you build it, it shows up in your Content Browser just like any other Fortnite device. You drag it onto your island, hit **Launch Session**, and your code runs when players start the game!

Think of it like baking a cake 🎂:
1. You write the **recipe** (Verse code).
2. You **bake** it (compile the code).
3. You **put it on the table** (drag the device into the level).
4. Everyone **eats it** (plays the game and your code runs!).

---

### 🗂️ Key Words to Know

| Word | What it means |
|---|---|
| **Verse** | Epic's programming language for Fortnite islands |
| **UEFN** | The app (Unreal Editor for Fortnite) where you build islands |
| **Device** | A pre-built game object you can place on your island |
| **Verse device** | A custom device *you* build with Verse code |
| **Compile** | Turning your code into something the game can run (like baking the recipe) |
| **Playtest** | Running your island to test it, like a rehearsal |

---

### 🧭 How to Create Your First Verse Device — Step by Step

Follow these steps inside UEFN:

1. **Open Verse Explorer** — In the top menu bar, click **Verse**, then **Verse Explorer**.
2. **Add a new Verse file** — Right-click your project name and choose **Add new Verse file to project**.
3. **Pick the template** — In the window that pops up, click **Verse Device**.
4. **Name your device** — Type a name in the **Device Name** box. Let's call ours `welcome_device`.
5. **Click Create** — Your new file appears in Verse Explorer!
6. **Open the file** — Double-click it to open it in **Visual Studio Code** (a free code editor).

> ✅ Great job — you just created your first Verse file! Give yourself a high-five. 🙌

---

### 🔨 Compile and Place Your Device

Before you can use your device in the game, you have to **compile** it. Compiling means the editor reads your code and turns it into something the game understands.

1. In the menu bar, go to **Verse > Build Verse Code**.
2. Look in your **Content Browser** under the **CreativeDevices** folder. Your device should appear there!
3. **Drag** the device into your level (the island map).
4. Click **Launch Session** in the toolbar to playtest. Click **Start Game** when Fortnite opens.

Your code is now running on your island. 🎉

### Worked Example

### 🔬 Worked Example: Your First Verse Device Code

When UEFN creates a new Verse Device, it gives you a starter template. Here's what that code looks like, with friendly explanations for every line:

```verse
# This line says: "Use the UEFN game tools in this file."
using { /fortnite.com/devices }

# This line says: "Use general Verse tools (math, text, etc.)."
using { /verse.org/simulation }

# Here we DEFINE our device.
# "my_device" is its name. "creative_device" means it works as a Fortnite island device.
my_device := class(creative_device):

    # OnBegin is a special function that runs ONCE when the game starts.
    # Think of it like the starting pistol at a race — BANG, code goes!
    OnBegin<override>()<suspends>:void=
        # This line prints a message to the game log.
        # It's how you check "did my code run?"
        Print("Hello, island! My first device is working!")
```

#### 🚶 Walkthrough

| Line | What's happening |
|---|---|
| `using { /fortnite.com/devices }` | Loads all the Fortnite device tools we need |
| `using { /verse.org/simulation }` | Loads core Verse tools |
| `my_device := class(creative_device):` | Creates our new device type and names it `my_device` |
| `OnBegin<override>()<suspends>:void=` | This is a **function** — a named set of instructions. `OnBegin` runs at the very start of the game. |
| `Print("Hello, island! ...")` | Shows a message in the log so you know the code ran |

> 🎯 **Function** — a named set of instructions. Like a move in a dance routine: "do the spin" means the same steps every time you say it.

> 🎯 **OnBegin** — a special built-in function in UEFN that fires once when the round starts. Every Verse device has one.

After you compile and drag this device onto your island, launch a session. Check the **Output Log** (Window > Output Log in UEFN) and you'll see your message pop up when the game starts! 🎊

### Try It Yourself

### 🏋️ Your Turn: Customize Your First Device

You've seen the starter code. Now make it your own!

**Your mission:**

1. Open your `welcome_device` Verse file in Visual Studio Code.
2. Change the message inside `Print(...)` to say something about **your** island. For example:
   - `"Welcome to my awesome ninja course!"`
   - `"Get ready — this island is going to be wild!"`
3. **Save** the file (Ctrl+S on Windows, Cmd+S on Mac).
4. Go back to UEFN and click **Verse > Build Verse Code** to compile.
5. If your device is already in the level, launch a session and check the **Output Log** for your message.

**🌟 Bonus challenge:** Can you add a *second* `Print(...)` line right below the first one with a different message? Try it!

> 💡 **Hint:** Each `Print` statement goes on its own line, indented the same amount as the first one. Make sure the text is wrapped in `" "` quote marks.

> 🤔 **Stuck?** Check that your quotes are straight (`"`) not curly (`""`), and that each line inside `OnBegin` starts with the same spacing (indentation) as the example.

### Quiz

1. What is Verse?
   - A. A Fortnite weapon that shoots code
   - B. A programming language made by Epic Games for building Fortnite islands
   - C. A device you place on your island to add music
   - D. The name of the UEFN menu bar

2. What does 'compiling' your Verse code mean?
   - A. Deleting your code so you can start over
   - B. Saving a screenshot of your island
   - C. Turning your code into something the game engine can actually run
   - D. Dragging a device into your level

3. What does the OnBegin function do in a Verse device?
   - A. It runs every second while the game is playing
   - B. It runs once when a player picks up an item
   - C. It runs once at the very start of the game round
   - D. It runs when the game ends

4. After compiling your Verse device, where do you find it to place it on your island?
   - A. In the Verse Explorer panel
   - B. In the Output Log window
   - C. In the CreativeDevices folder inside the Content Browser
   - D. In the Visual Studio Code sidebar

**Answer key:**

1. B — Verse is Epic Games' programming language. You use it to write custom instructions for your Fortnite island — like a recipe the game follows!
2. C — Compiling is like baking a recipe. You wrote the instructions (code), and now the editor 'bakes' them into something the game can use. Without compiling, your device won't show up!
3. C — OnBegin is the 'starting pistol' of your device. It fires exactly once when the round begins, so anything you put inside it happens right at the start of the game.
4. C — Once you compile, UEFN puts your new device in the CreativeDevices folder in the Content Browser — right alongside all the other Fortnite devices. Then you drag it onto your island!

### Recap

### 🌟 Lesson Recap

**Verse** is Epic Games' programming language that lets you create custom rules and devices for your Fortnite island — things no normal device can do on its own. You use **UEFN** (Unreal Editor for Fortnite) to write Verse code, **compile** it (bake it!), and drag your new device into your level. Every Verse device has an **OnBegin** function that runs your code the moment the game starts. You're officially a Verse coder now — keep building! 🚀

**Sources:**

- /docs/documentation/en-us/fortnite/verse-language-get-started-in-unreal-editor-for-fortnite
- /docs/documentation/en-us/uefn/create-your-own-device-in-verse

---

## Lesson 2: Spawning Players and Handling Player Join/Leave Events

**Objectives:**

- Explain what a player-join event and a player-leave event are, using a game analogy.
- Write a Verse script that detects when a player joins your island and prints a welcome message.
- Write a Verse script that detects when a player leaves your island and prints a goodbye message.
- Place a Player Spawner device and connect it to your Verse script so new players appear on your island.

### 🎮 Welcome to Your Island — Who Just Walked In?

Imagine your island is a party. 🎉
Every time a friend walks through the door, you want to say **"Hey, welcome!"**
And when someone leaves, you want to say **"See you later!"**

In Verse, you can do exactly that — with something called **events**.

---

### 📣 What Is an Event?

An **event** is something that happens during the game that your code can *listen* for and react to.

Think of it like a doorbell. 🔔
- The doorbell **rings** = the event happens.
- You **answer the door** = your code runs.

Two super important events in UEFN are:

| Event | When it fires |
|---|---|
| `PlayerAddedEvent` | A player **joins** your island |
| `PlayerRemovedEvent` | A player **leaves** your island |

These come from the **game session** — think of the game session as the referee who keeps track of everyone playing.

---

### 🧍 What Is a Player?

In Verse, every person playing your game is a **`player`** — that's the word Verse uses for a real human in the game.

When an event fires, Verse hands your code that `player` like a backstage pass 🪪. You can use it to do things *to* or *for* that specific person.

---

### 🪄 What Is `GetPlayspace`?

Your island in UEFN has a **playspace**. A playspace is like the stage where the whole game happens. It knows about every player on the island.

You call `GetPlayspace()` to get access to that stage. Once you have it, you can subscribe to (meaning: start listening to) the join and leave events.

---

### 🔗 What Does "Subscribe" Mean?

**Subscribing** to an event means telling Verse: *"Hey, when this thing happens, please run my function."*

It's like signing up for text alerts. 📱
Once you subscribe, every time the event fires, your function automatically runs!

---

### 🏁 Where Does Setup Code Go?

In a UEFN Verse device, there is a special function called **`OnBegin`**. It runs **once**, right when the game starts — like pressing the START button.

This is the perfect place to subscribe to events, because you want to start listening right away!

---

### 🪃 What Is a `player_spawner_device`?

A **Player Spawner** is a device you place on your island in UEFN. It marks a spot where players appear when they join. Think of it like a respawn pad. 🟢

You can reference it in your Verse script using `player_spawner_device`. But for basic joining/leaving detection, the events do all the heavy lifting — the spawner just controls *where* players pop in.

---

### 🧩 Putting It All Together

Here's the big picture of what your script will do:

1. ⏱️ Game starts → `OnBegin` runs.
2. 👂 You subscribe to the join and leave events.
3. 🧍 A player joins → your "welcome" function runs automatically.
4. 👋 A player leaves → your "goodbye" function runs automatically.

That's it! You're writing code that *reacts* to real players in real time. How cool is that? 🚀

### Worked Example

### 🔨 Worked Example: Greet Players When They Join or Leave

Let's build a simple script. It will say hello when someone joins and goodbye when someone leaves.

**Step 1 — In UEFN**, create a new Verse device file called `player_greeter`. Add a **Player Spawner** device to your island and place it somewhere flat.

**Step 2 — Here is the full Verse code:**

```verse
# This tells Verse we are making a device (like a prop that has code inside it).
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# We define our device — think of it like a recipe card for our gadget.
player_greeter := class(creative_device):

    # OnBegin runs once when the game starts — like pressing START.
    OnBegin<override>()<suspends> : void =
        # GetPlayspace() gives us access to the whole game stage.
        Playspace := GetPlayspace()

        # Subscribe means "hey, call my function when this event fires."
        # PlayerAddedEvent fires every time a new player joins.
        Playspace.PlayerAddedEvent().Subscribe(OnPlayerJoined)

        # PlayerRemovedEvent fires every time a player leaves.
        Playspace.PlayerRemovedEvent().Subscribe(OnPlayerLeft)

    # This function runs automatically when a player JOINS.
    # Verse passes us the player who just joined — we call them NewPlayer.
    OnPlayerJoined(NewPlayer : player) : void =
        # Print sends a message to the Output Log so you can see it.
        Print("A new player just joined the island! 🎉")

    # This function runs automatically when a player LEAVES.
    # Verse passes us the player who just left — we call them LeavingPlayer.
    OnPlayerLeft(LeavingPlayer : player) : void =
        Print("A player left the island. 👋 See you next time!")
```

---

### 🗺️ Walkthrough — Line by Line

| What the code says | What it means in plain English |
|---|---|
| `using { /Fortnite.com/Devices }` | "I want to use UEFN devices in my script." |
| `player_greeter := class(creative_device)` | "My gadget is a creative device — it lives on the island." |
| `OnBegin<override>()<suspends> : void` | "This runs once at the start of the game." |
| `GetPlayspace()` | "Give me the game stage so I can listen to events." |
| `PlayerAddedEvent().Subscribe(OnPlayerJoined)` | "Every time someone joins, call my OnPlayerJoined function." |
| `PlayerRemovedEvent().Subscribe(OnPlayerLeft)` | "Every time someone leaves, call my OnPlayerLeft function." |
| `OnPlayerJoined(NewPlayer : player) : void` | "This is my welcome function. It receives the player who joined." |
| `Print(...)` | "Show this message in the Output Log." |

---

### ✅ How to Test It

1. Save your Verse file and click **Verse → Build Verse Code** in UEFN.
2. Drag your `player_greeter` device onto the island.
3. Press **Launch Session** (the play button).
4. Open the **Output Log** window.
5. When the session loads, look for your printed messages! 🎊

> 💡 **Pro Tip:** In a real multiplayer session, every player who joins will trigger `OnPlayerJoined`. Each player is handled separately — Verse keeps track of them one by one!

### Try It Yourself

### 🏋️ Your Turn — Make It Personal!

You just learned how to detect players joining and leaving. Now level it up!

**Your Challenge:**

Right now the script prints the same message for every player. Your job is to **count how many players are on the island** and print the count each time someone joins.

Here are some hints to guide you:

- **Hint 1:** You need a **variable** to keep track of the count. Remember — a variable is something that *changes* during the game. In Verse, you can write a mutable (changeable) variable like this inside your class:
  ```verse
  var PlayerCount : int = 0
  ```
  `int` means a whole number (like 1, 2, 3).

- **Hint 2:** Inside `OnPlayerJoined`, you can increase the count by 1 like this:
  ```verse
  set PlayerCount += 1
  ```

- **Hint 3:** You can print the count inside a message. Try building a string with `ToString()`:
  ```verse
  Print("Players on island: {PlayerCount}")
  ```

- **Hint 4:** Don't forget — when a player *leaves*, you should **decrease** the count by 1 too! Use `set PlayerCount -= 1` inside `OnPlayerLeft`.

**Bonus Challenge 🌟:** Can you also print a special message when `PlayerCount` reaches 3? (Hint: use an `if` statement — `if (PlayerCount = 3):`)

Give it a try! You've got everything you need. You're doing amazing! 💪

### Quiz

1. What does the `PlayerAddedEvent` do in Verse?
   - A. It adds a new prop to the island.
   - B. It fires when a new player joins the game.
   - C. It gives every player extra health.
   - D. It starts a countdown timer.

2. What does it mean to "subscribe" to an event?
   - A. To delete the event so it never happens.
   - B. To make the game pause until the event fires.
   - C. To tell Verse: run my function whenever this event happens.
   - D. To add a new device to the island.

3. Where should you subscribe to player events so they work from the very start of the game?
   - A. Inside the OnPlayerJoined function.
   - B. Inside the OnBegin function.
   - C. At the very bottom of the file, outside any function.
   - D. Inside the PlayerRemovedEvent itself.

4. What does `GetPlayspace()` give you?
   - A. A list of all props on the island.
   - B. The player's current health points.
   - C. Access to the game stage, where all players are tracked.
   - D. A new Player Spawner device.

**Answer key:**

1. B — PlayerAddedEvent fires (goes off) every time a new player joins your island — like a doorbell ringing when a friend arrives!
2. C — Subscribing is like signing up for text alerts. Once you subscribe, your function runs automatically every time the event fires. You don't have to check manually!
3. B — OnBegin runs once when the game starts — just like pressing the START button. It's the perfect place to set up your event listeners so they're ready before any player joins!
4. C — GetPlayspace() gives you the "game stage" — the thing that knows about every player. You need it to access events like PlayerAddedEvent and PlayerRemovedEvent.

### Recap

### 🌟 Great Work — Here's What You Learned!

Today you learned that **events** are like doorbells — they fire when something happens, and your code reacts. You used `PlayerAddedEvent` and `PlayerRemovedEvent` to detect players joining and leaving your island. You put your setup code inside `OnBegin` so it runs the moment the game starts. Now your island can actually *know* when players arrive and say goodbye — that's the foundation of almost every multiplayer game! 🎮

**Sources:**

- /docs/documentation/en-us/uefn/verse-prop-hunt-template-in-unreal-editor-for-fortnite
- /docs/documentation/en-us/fortnite/prop-hunt-template-in-unreal-editor-for-fortnite

---

## Lesson 3: Building a Score Tracking System

**Objectives:**

- Explain what a variable is and why it changes during a game
- Create a Verse script that tracks a player's score using a variable
- Use a Trigger device to add points when a player does something in the game
- Display score changes by connecting Verse logic to in-game devices

### 🎮 Let's Build a Score Tracker!

Imagine you are playing a Fall Guys obstacle course. Every time you finish a checkpoint, your score goes up. How does the game *remember* your score? That is exactly what we are going to learn today!

---

### 🧠 What is a Variable?

A **variable** is like a scoreboard in a gym. It holds a number (or other information), and that number can **change** while the game is running.

Think of it like this: imagine a whiteboard that says **"Player Score: 0"**. When you tag a checkpoint, someone erases the 0 and writes **10**. Then **20**. That whiteboard is your variable!

- The **name** on the whiteboard is the variable's name (like `PlayerScore`).
- The **number** written on it is the variable's **value**.
- The value can **change** anytime during the game.

> 💡 **Variable** = a named box that holds information and can be updated while the game runs.

---

### 🧊 What is a Constant?

A **constant** is like a painted wall in your island. You pick the color *before* the game starts, and it never changes during the game. Constants are set **once** and stay the same forever.

For example, the number of points each checkpoint gives you might always be **10**. That never changes, so it can be a constant!

> 💡 **Constant** = a named box whose value is **locked** and never changes.

---

### 🏁 How This Works in a Fall Guys Island

Here is the plan for our mini-game:

1. A player runs through a **Trigger device** (like stepping on a checkpoint).
2. Our Verse code **listens** for that trigger.
3. When it fires, the code **adds 10 points** to the player's score variable.
4. The score is sent to a **HUD Message device** so the player can see it!

This is like a scoreboard that automatically updates every time something exciting happens in your game.

---

### 📦 The Devices We'll Use

| Device | What It Does |
|---|---|
| **Trigger Device** | Fires an event when a player walks into it |
| **HUD Message Device** | Shows a message (like a score) on screen |

Both of these devices exist in UEFN's Creative device list. Place them on your island before writing code!

---

### 🔗 Connecting Verse to Devices

In Verse, we can **reference** (point to) a device we placed on our island. Think of it like naming a toy in your room. Once it has a name in your code, you can tell it what to do!

We use a special tag called `@editable` to connect a device in our code to a real device on the island. It is like labeling a box so you know exactly which toy is inside.

### Worked Example

### 🛠️ Worked Example: The Checkpoint Score Tracker

Here is a complete Verse script. Read the comments (the lines starting with `#`) — they explain every important line!

```verse
# We are creating a new "game manager" that runs on our island.
# Think of it like the referee of our Fall Guys game!
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

score_tracker := class(creative_device):

    # @editable means we can connect this to a REAL device on our island.
    # This is our Trigger device — the "checkpoint" the player walks through.
    @editable
    CheckpointTrigger : trigger_device = trigger_device{}

    # @editable connects to our HUD Message device so we can show the score.
    @editable
    ScoreDisplay : hud_message_device = hud_message_device{}

    # This is our VARIABLE. It starts at 0 and will go UP as players score.
    # "var" means it can change — just like our scoreboard whiteboard!
    var PlayerScore : int = 0

    # This is a CONSTANT. It is always 10 — the points per checkpoint.
    # "PointsPerCheckpoint" never changes during the game.
    PointsPerCheckpoint : int = 10

    # OnBegin runs automatically when the island starts — like pressing Play!
    OnBegin<override>()<suspends> : void =
        # We tell the trigger: "When someone walks in, call AddPoints."
        # This is called SUBSCRIBING to an event.
        CheckpointTrigger.TriggeredEvent.Subscribe(OnCheckpointTriggered)

    # This function runs every time the trigger fires.
    # A FUNCTION is a set of instructions with a name — like a recipe step.
    OnCheckpointTriggered(TriggeringAgent : ?agent) : void =
        # Add PointsPerCheckpoint to our PlayerScore variable.
        # "set" is how we UPDATE a variable in Verse.
        set PlayerScore = PlayerScore + PointsPerCheckpoint

        # Show a message on screen so the player sees their new score.
        ScoreDisplay.Show()

        # Print to the output log so we can debug (check) our work.
        Print("Score is now: {PlayerScore}")
```

---

### 🗺️ Walkthrough — Step by Step

**Step 1 — Set up devices on your island:**
- Place a **Trigger device** somewhere players will walk through (a checkpoint!).
- Place a **HUD Message device** anywhere on the island.

**Step 2 — Create the Verse file:**
- In UEFN, go to **Verse > Create New Verse File**.
- Paste the code above into your new file.
- Click **Compile** to check for errors.

**Step 3 — Connect the devices:**
- Click on your `score_tracker` actor in the Outliner.
- In the Details panel, you will see `CheckpointTrigger` and `ScoreDisplay`.
- Drag your Trigger device into `CheckpointTrigger` and your HUD Message device into `ScoreDisplay`.

**Step 4 — Play and test!**
- Press **Launch Session** and walk through your trigger.
- Watch the score go up by 10 each time! 🎉

> ✅ **You did it!** Every time you walk through the trigger, `PlayerScore` grows. The variable is doing its job — remembering and updating the score!

### Try It Yourself

### 🏆 Your Turn: Double the Fun!

You have the basic score tracker working. Now let's make it more exciting!

**Your challenge:** Add a **second trigger** that gives the player **25 points** instead of 10 — like a special bonus checkpoint!

Here is what you need to do:

1. **Place a second Trigger device** on your island. Make it look special (maybe put it somewhere hard to reach!).
2. **Add a second `@editable` variable** in your Verse class to reference this new trigger. You could call it `BonusTrigger`.
3. **Subscribe** to this new trigger's `TriggeredEvent` inside `OnBegin`, just like you did for the first trigger.
4. **Write a new function** called `OnBonusTriggered` that adds **25 points** to `PlayerScore` and calls `ScoreDisplay.Show()`.

> 💡 **Hint:** Your new function will look almost exactly like `OnCheckpointTriggered`. The only things that change are the function name and the number of points added! Try using a new constant called `BonusPoints : int = 25`.

> 🌟 **Bonus challenge:** Can you make the score **reset back to 0** if the player falls off the map? Think about where you might add `set PlayerScore = 0` in your code!

### Quiz

1. What is a variable in a game?
   - A. A wall that never changes color during the game
   - B. A named box that holds information and can change while the game runs
   - C. A device you place on your island in UEFN
   - D. The name of the island you are building

2. In our score tracker, what does the keyword 'set' do?
   - A. It creates a brand-new variable for the first time
   - B. It deletes the variable from memory
   - C. It updates (changes) the value stored in a variable
   - D. It connects a device to our Verse script

3. What does @editable do in a Verse script?
   - A. It makes the variable change faster during the game
   - B. It lets you connect a real island device to your Verse code in the Details panel
   - C. It prints a message to the screen for the player
   - D. It stops the variable from ever changing

4. What is the difference between a variable and a constant?
   - A. A variable is used for text, and a constant is used for numbers
   - B. A variable can change during the game, but a constant is set once and never changes
   - C. A constant is bigger than a variable
   - D. There is no difference — they work exactly the same way

**Answer key:**

1. B — A variable is like a scoreboard whiteboard — it holds a value (like a score) that can be updated anytime during the game. The wall that never changes is more like a constant!
2. C — The 'set' keyword is how we UPDATE a variable in Verse. It is like erasing the old number on the whiteboard and writing the new one. We use 'set PlayerScore = PlayerScore + 10' to add 10 to the score!
3. B — @editable is like putting a label on a box. It lets you drag a real device from your island into that 'slot' in your Verse class, so the code knows exactly which device to talk to!
4. B — Great question! A variable (like PlayerScore) can change many times while the game runs. A constant (like PointsPerCheckpoint = 10) is locked in place — it never changes. Think of a constant like a painted wall and a variable like a whiteboard!

### Recap

### 🌟 Great Work — Here's What You Learned!

Today you built a **real score tracking system** for a Fortnite island! You learned that a **variable** is like a scoreboard that updates during the game, while a **constant** is a locked-in value that never changes. You used a **Trigger device** to fire events and Verse code to listen for those events and add points. Now every time a player hits your checkpoint, the score goes up — and your island feels like a real game! Keep building! 🎮

**Sources:**

- /docs/documentation/en-us/fortnite/30-30-fortnite-ecosystem-updates-and-release-notes-in-creative-and-unreal-editor-for-fortnite

---

## Lesson 4: Implementing Round Logic and Game Flow

**Objectives:**

- Explain what a round is in a Fortnite island and why round logic matters
- Create a persistable class to store player round data across rounds
- Use a weak_map to connect each player to their round information
- Write functions to record player finish order and reset data between rounds

### 🏁 What Is Round Logic?

Imagine you are playing a racing board game. After each lap, you write down who finished first, second, and third. Then the **next lap starts** — and whoever won gets to start ahead of everyone else. That's **round logic**!

In Fortnite islands, rounds work the same way. The game needs to remember:
- **What round are we on right now?**
- **In what order did players finish the last round?**

We use Verse code to track all of this — and that's exactly what this lesson is about! 🎉

---

### 📦 New Word: Class

A **class** is like a **lunchbox**. It holds several pieces of information together in one neat container. For example, a `player_circuit_info` class (circuit = racing track) holds:
- Which round the player last finished
- What place they finished in (1st, 2nd, 3rd…)

---

### 💾 New Word: Persistable

**Persistable** means the data **sticks around** between rounds — like writing something in permanent marker instead of dry-erase marker. If something is *not* persistable, it gets erased when a new round starts.

We use `<persistable>` to tell Verse: *"Don't erase this data when the round resets!"*

---

### 🗺️ New Word: Weak Map

A **weak_map** is like a **hall of lockers** at school. Each locker belongs to one player. Inside the locker you store that player's info. When you need to check someone's round info, you look up their locker.

In Verse, a `weak_map(player, player_circuit_info)` maps (connects) every player to their own `player_circuit_info` lunchbox.

---

### 🔢 What Does `-1` Mean?

When a player first joins, they haven't finished any round yet. We set their finish order and round number to **`-1`** as a placeholder — like an empty locker. It means *"no real data yet."* When the player finishes a round, we replace `-1` with a real number.

---

### 🔄 New Word: Constructor

A **constructor** is a helper function that builds a *new* copy of a class. Think of it like a **photocopier for lunchboxes** — it copies all the contents, and you can swap out just one item before sealing the new copy. This is handy when you want to update only one field (like finish order) without losing everything else.

---

### 🏎️ How the Round Flow Works

Here is the big picture, step by step:

1. 🟢 **Round Starts** — Players spawn at positions based on last round's finish order.
2. 🏁 **Players Race** — The first one to cross the finish line gets recorded as 1st place, and so on.
3. 📝 **Record Results** — We call `RecordPlayerFinishOrder` to save each player's place in their locker.
4. 🔁 **Round Ends** — We update each player's "last completed round" number.
5. 🧹 **Next Round Begins** — Spawn positions are set using last round's saved finish order. Repeat!

---

### 🌳 Scene Graph Tip

In Verse and Unreal Engine, everything on your island is part of a **scene graph** — a giant family tree of objects. Each device (like a Trigger or a Checkpoint) is a **node** (a dot on the tree). When you attach a script to a device, that script becomes a **component** of that node.

Your round-logic script sits at the top of this tree — it watches over ALL the checkpoints and players like a **game referee**. When a player hits a checkpoint (a child node), it reports up to your script (the parent node), which updates the player's locker in the weak map. This parent-child flow is the scene graph in action! 🌲

### Worked Example

### 🛠️ Full Worked Example: Tracking Player Round Info

Here is a complete, real Verse script you can use in UEFN. Read the comments (lines starting with `#`) — they explain every important line!

```verse
# This file goes on a Verse device in your UEFN project.
# It tracks which round each player finished, and in what order.

using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# -------------------------------------------------------
# STEP 1: Define our "lunchbox" class.
# <persistable> means this data survives between rounds.
# <final> means nobody can remix this class into a new one.
# -------------------------------------------------------
player_circuit_info<public> := class<final><persistable>:
    Version : int = 0                    # helps manage saved data versions
    LastRoundFinishOrder<public> : int = -1   # -1 = "not set yet"
    LastCompletedRound<public> : int = -1     # -1 = "not set yet"

# -------------------------------------------------------
# STEP 2: A constructor — our "photocopier for lunchboxes."
# It copies an old player_circuit_info so we can change just one field.
# <transacts> means: if something goes wrong, undo all changes safely.
# -------------------------------------------------------
MakePlayerCircuitInfo<constructor>(Old : player_circuit_info)<transacts> := player_circuit_info:
    Version := Old.Version                          # copy the version
    LastRoundFinishOrder := Old.LastRoundFinishOrder # copy the finish order
    LastCompletedRound := Old.LastCompletedRound     # copy the round number

# -------------------------------------------------------
# STEP 3: Our main round-manager device class.
# -------------------------------------------------------
round_manager<public> := class(creative_device):

    # The hall of lockers — one locker per player.
    # weak_map means: if a player leaves, their locker is automatically cleaned up.
    var CircuitInfo<public> : weak_map(player, player_circuit_info) = map{}

    # How many rounds total in this game session?
    TotalRounds<public> : int = 3

    # Which round are we on right now? Starts at 1.
    var CurrentRound<public> : int = 1

    # ---------------------------------------------------
    # STEP 4: Record a player's finish position for this round.
    # Agent = the player who crossed the finish line.
    # FinishOrder = 1 for 1st place, 2 for 2nd place, etc.
    # <decides> means this function can "fail" safely if the player isn't found.
    # ---------------------------------------------------
    RecordPlayerFinishOrder<public>(Agent : agent, FinishOrder : int)<decides><transacts> : void =
        # Try to get the player from the agent — agents include NPCs, players share this type
        Player := player[Agent]
        # Make sure the player is still in the game (not disconnected)
        Player.IsActive[]

        # Look up the player's existing lunchbox, or make a fresh empty one
        PlayerCircuitInfo : player_circuit_info =
            if (Info := CircuitInfo[Player]):
                Info           # player already has a lunchbox — use it
            else:
                player_circuit_info{}   # brand new empty lunchbox

        # Use the photocopier (constructor) to make a new lunchbox
        # but swap in the new FinishOrder value
        set CircuitInfo[Player] = player_circuit_info:
            MakePlayerCircuitInfo<constructor>(PlayerCircuitInfo)
            LastRoundFinishOrder := FinishOrder      # update ONLY the finish order
            LastCompletedRound := CurrentRound       # also record which round this was

    # ---------------------------------------------------
    # STEP 5: Move to the next round, or end the game.
    # ---------------------------------------------------
    AdvanceRound<public>() : void =
        if (CurrentRound < TotalRounds):
            set CurrentRound = CurrentRound + 1   # go to the next round
            Print("Starting round {CurrentRound}!")
        else:
            Print("All rounds done! Game over!")
            # Here you would trigger your end-game logic

    # ---------------------------------------------------
    # STEP 6: Reset a player's round info (e.g., when they leave or game ends).
    # ---------------------------------------------------
    ResetPlayerInfo<public>(Agent : agent)<decides><transacts> : void =
        Player := player[Agent]
        Player.IsActive[]
        # Overwrite their locker with a fresh, empty lunchbox
        set CircuitInfo[Player] = player_circuit_info{}
```

---

### 🔍 Walkthrough

| Step | What it does | Real-world analogy |
|---|---|---|
| `player_circuit_info` class | Defines the lunchbox shape | Designing what goes in a locker |
| `weak_map` | Hall of lockers, one per player | Each student has their own locker |
| `MakePlayerCircuitInfo` constructor | Photocopies the lunchbox with one change | Update one item without emptying everything |
| `RecordPlayerFinishOrder` | Saves a player's place at race end | Writing their finish time on a scorecard |
| `AdvanceRound` | Moves the game to the next round | Flipping to the next page of the scorebook |
| `ResetPlayerInfo` | Clears a player's data | Emptying and cleaning their locker |

### Try It Yourself

### 🎮 Your Turn: Build a 2-Round Race Island!

Now it's time to build something you can actually **play**! Follow these steps:

#### What You'll Build
A simple 2-round race where:
- Players race through **Checkpoint devices** to finish the round.
- When the round ends, the game **prints each player's finish order** to the screen.
- After 2 rounds, the game announces **"Game Over!"**

---

#### Steps

1. **In UEFN**, create a new island and place **2 Checkpoint devices** and **1 End Zone device** on a simple track.

2. **Add a Verse device** to your island and paste the `round_manager` code from the worked example above.

3. **Wire up the End Zone** — when a player enters it, call `RecordPlayerFinishOrder` with that player and the current finish count (1st person in = order 1, 2nd person = order 2, etc.).

4. **After all players finish**, call `AdvanceRound()` to move to round 2.

5. Set `TotalRounds` to `2` in your device settings.

6. **Play your island!** Watch the `Print` messages appear in the top-left of your screen.

---

#### 🧩 Challenge (Stretch Goal!)

Can you add a **Print statement** inside `RecordPlayerFinishOrder` that says:
> *"Player finished in place [FinishOrder] during round [CurrentRound]!"*

**Hint:** In Verse, you print text like this:
```verse
Print("Player finished in place {FinishOrder} during round {CurrentRound}!")
```
Place it right after the `set CircuitInfo[Player] = ...` line. You've got this! 💪

### Quiz

1. What does a weak_map do in Verse?
   - A. It makes the game run slower on purpose
   - B. It connects each player to their own stored information, like a hall of lockers
   - C. It deletes all player data at the start of every round automatically
   - D. It is a type of Fortnite weapon that deals weak damage

2. Why do we set LastRoundFinishOrder and LastCompletedRound to -1 at the start?
   - A. Because -1 is Verse's lucky number
   - B. Because negative numbers run faster in Verse
   - C. Because -1 is a placeholder meaning 'no real data yet' — the player hasn't finished a round
   - D. Because Verse only understands negative numbers for player data

3. What does the <persistable> specifier do to a class?
   - A. It makes the class run in a loop forever
   - B. It means the data in that class survives between rounds and isn't erased
   - C. It deletes the class after one round
   - D. It makes the class only work for NPCs, not real players

4. In the scene graph, why is the round_manager script described as a 'parent node'?
   - A. Because it was created before any other node in the island
   - B. Because it is the tallest device on the island
   - C. Because it watches over and receives reports from all the checkpoint devices (child nodes) below it
   - D. Because parent nodes always run slower than child nodes

**Answer key:**

1. B — A weak_map is like a hall of lockers — each player gets their own locker where you can store their personal data. If a player leaves the game, their locker is automatically cleaned up!
2. C — -1 is used as a placeholder, like an empty locker. It tells us that no real finish order has been recorded yet. Once the player finishes a round, we replace -1 with their actual position.
3. B — Persistable means 'stick around!' — like writing in permanent marker. Data marked <persistable> survives when a new round starts, so you can use it to remember what happened in the previous round.
4. C — In a scene graph, parent nodes sit above child nodes in the family tree. The round_manager is the referee at the top — checkpoints and other devices report events UP to it, just like kids reporting to a teacher!

### Recap

### 🌟 Great Work — Here's What You Learned!

You built a real **round management system** for a Fortnite race island! You learned that a **`weak_map`** is like a hall of lockers — one per player — and a **`persistable` class** keeps data safe between rounds, like writing in permanent marker. A **constructor** lets you update just one field without losing all the other data, like swapping one item in a lunchbox. Put it all together and you have a system that tracks finish order, advances rounds, and resets player data — the backbone of any great multi-round Fortnite experience! 🏁🎉

**Sources:**

- /docs/documentation/en-us/fortnite/custom-round-logic-using-verse

---

## Lesson 5: Creating Win Conditions and Ending the Game

**Objectives:**

- Explain what a win condition is and why every game needs one
- Use an End Game Device to stop a Fortnite island when a player wins
- Subscribe to the EliminatedEvent to count player eliminations in Verse
- Check an elimination count against a winning number and trigger the End Game Device

### 🏆 What Is a Win Condition?

Every game has a moment when someone **wins**. In checkers, you win when you take all your opponent's pieces. In a race, you win when you cross the finish line first.

In Fortnite, your island needs the same thing — a rule that says *"You did it! Game over!"*

That rule is called a **win condition**. It's just an **if-then** idea:

> **If** something happens enough times → **then** end the game and celebrate the winner!

---

### 🧩 The Pieces We Need

Think of building this like a LEGO set. We need three pieces:

| Piece | What It Does |
|---|---|
| **EliminatedEvent** | Tells our code every time a player is eliminated |
| **A counter (variable)** | Keeps score — it counts up each elimination |
| **End Game Device** | The magic button that actually ends the round |

---

### 📦 What Is a Variable?

A **variable** is like a scoreboard that changes during the game.

Imagine a whiteboard in gym class. You erase the old score and write a new one every time a team scores. That whiteboard is a variable — it changes!

In Verse, we write `var` in front of a variable name to say *"hey, this number is allowed to change."*

```verse
var EliminationCount : int = 0   # starts at zero, like a fresh scoreboard
```

`int` just means the value is a **whole number** (like 0, 1, 2, 3 — not 1.5).

---

### 🔔 What Is an Event Subscription?

Imagine you sign up for text alerts from a pizza place. Every time a new deal drops, you get a message automatically — you don't have to keep checking!

**Subscribing to an event** works the same way. We tell Verse:

> "Hey, every time a player gets eliminated, automatically run my special function!"

That special function is called an **event handler**. It's the code that runs when the event happens.

We subscribe like this:

```verse
FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)
```

This says: *"When this character is eliminated, call my function named `OnPlayerEliminated`."*

---

### 🛑 What Is the End Game Device?

The **End Game Device** is a real UEFN device you place on your island. When your Verse code tells it to **Activate**, it ends the round — just like a referee blowing the final whistle!

We call it like this:

```verse
EndGameDevice.Activate(Player)
```

`Player` is who triggered the win — so Fortnite knows who to celebrate! 🎉

---

### 🗺️ Putting It All Together

Here is the big picture in plain English:

1. When the game **starts**, set the winning number (like "first to 3 eliminations wins").
2. Subscribe to the **EliminatedEvent** for every player.
3. Every time someone gets an elimination, **add 1 to the scoreboard**.
4. **Check** if the scoreboard reached the winning number.
5. If YES → **Activate the End Game Device** → 🎉 Winner!

That's it! Let's see it in real Verse code.

### Worked Example

### 🛠️ Building the Win Condition — Step by Step

Before you write code, place these devices on your island in UEFN:
- ✅ **1 × End Game Device** (use default settings)
- ✅ **2 or more × Player Spawn Pads** (spread them out)

Now create a new Verse device script and copy the code below.

```verse
# These lines "import" tools we need — like opening your toolbox
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }

# Our device is a class — think of it like a blueprint for a machine
win_condition_device := class(creative_device):

    # @editable lets us drag the End Game Device in from the UEFN editor
    @editable
    EndGameDevice : end_game_device = end_game_device{}

    # This is our scoreboard — starts at 0, changes during the game
    var EliminationCount : int = 0

    # This is the winning number — first player to 3 eliminations wins!
    EliminationsToWin : int = 3

    # OnBegin runs automatically when the island starts — like pressing Play
    OnBegin<override>()<suspends> : void =

        # Get a list of everyone playing on the island
        AllPlayers := GetPlayspace().GetPlayers()

        # Loop through every player — like checking each name on a list
        for (Player : AllPlayers):

            # Try to get the player's Fortnite character body
            if (FortCharacter := Player.GetFortCharacter[]):

                # Sign up for alerts: "text me every time THIS character is eliminated"
                FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)

    # This function runs automatically each time ANY player is eliminated
    # The "eliminating_character" is the person who got the kill
    OnPlayerEliminated(Result : elimination_result) : void =

        # EliminatingCharacter is the player who scored the elimination
        if (EliminatingCharacter := Result.EliminatingCharacter[]):

            # Add 1 to the scoreboard — like making a tally mark
            set EliminationCount = EliminationCount + 1

            # Now CHECK: did someone reach the winning number?
            if (EliminationCount >= EliminationsToWin):

                # YES! End the game and crown the winner
                # We cast the character back to an agent so the device accepts it
                if (WinningPlayer := EliminatingCharacter.GetAgent[]):
                    EndGameDevice.Activate(WinningPlayer)
```

---

### 🚶 Walkthrough — What Each Part Does

| Part | What's happening |
|---|---|
| `@editable EndGameDevice` | Lets you drag your End Game Device into the script from the editor panel |
| `var EliminationCount : int = 0` | Our scoreboard — starts at zero |
| `EliminationsToWin : int = 3` | The finish line — 3 eliminations to win |
| `OnBegin` | Runs at game start; loops through players and signs up for elimination alerts |
| `FortCharacter.EliminatedEvent().Subscribe(...)` | "Text me every time this character is eliminated!" |
| `OnPlayerEliminated` | Runs automatically each time someone is eliminated |
| `set EliminationCount = EliminationCount + 1` | Adds 1 to the scoreboard (erases old number, writes new one) |
| `if (EliminationCount >= EliminationsToWin)` | Checks: *did we hit the winning number yet?* |
| `EndGameDevice.Activate(WinningPlayer)` | Blows the final whistle — game over, we have a winner! |

> 💡 **Pro Tip:** After writing the code, go to your Verse device in the UEFN editor. In the **Details panel**, drag your **End Game Device** into the `EndGameDevice` slot. If you skip this step, the game won't know which device to activate!

### Try It Yourself

### 🎮 Your Turn — Customize the Win Condition!

You just built a working win condition. Now let's make it your own!

**Challenge:** Change the game so a player needs **5 eliminations** to win instead of 3. Then add a `Print()` statement inside `OnPlayerEliminated` that shows the current score in the output log every time someone gets an elimination.

The `Print()` function works like this:

```verse
Print("Current eliminations: {EliminationCount}")
```

The curly braces `{}` around `EliminationCount` automatically drop the number into the message — like a fill-in-the-blank!

**Steps to try:**
1. Find the line `EliminationsToWin : int = 3` and change `3` to `5`.
2. Inside `OnPlayerEliminated`, right after you add 1 to the count, add a `Print()` line.
3. Save and push your Verse code.
4. Launch a session and test it — watch the output log tick up with each elimination!

> 🌟 **Bonus challenge:** Can you make the `EliminationsToWin` number `@editable` too, so you can change it right from the UEFN editor panel without touching the code? 

**Hint:** Look at how `EndGameDevice` uses `@editable` above it. The same trick works for numbers!

### Quiz

1. What does a 'win condition' do in a game?
   - A. It gives every player a free item at the start
   - B. It sets a rule for when the game should end and who wins
   - C. It spawns players onto the map
   - D. It changes a player's weapon automatically

2. What does 'subscribing to an event' mean in Verse?
   - A. Buying a Fortnite Battle Pass
   - B. Placing a device on the island
   - C. Telling your code to automatically run a function every time something happens
   - D. Setting a variable to zero at the start of the game

3. In the worked example, what does 'set EliminationCount = EliminationCount + 1' do?
   - A. It resets the scoreboard back to zero
   - B. It subtracts 1 from the score
   - C. It adds 1 to the scoreboard, like making a new tally mark
   - D. It ends the game immediately

4. Why do we use the End Game Device instead of just writing 'stop the game' in Verse?
   - A. Because Verse cannot use variables
   - B. Because the End Game Device is the real UEFN tool that handles ending a round, announcing the winner, and all the built-in game stuff
   - C. Because we have to use at least one device in every island
   - D. Because the End Game Device gives players extra items

**Answer key:**

1. B — A win condition is the rule that says 'if THIS happens, the game ends and someone wins!' Every game needs one so there's a clear finish line. 🏁
2. C — Subscribing to an event is like signing up for text alerts. You tell Verse: 'Every time THIS happens, run my function automatically!' You don't have to check — it just fires on its own. 📬
3. C — This line reads the current score, adds 1 to it, and saves the new number back. It's exactly like erasing 4 on a whiteboard and writing 5. 🖊️
4. B — The End Game Device is a built-in UEFN tool that handles all the complicated stuff — showing the winner, transitioning the round, etc. Our Verse code just tells it WHEN to activate. Teamwork! 🤝

### Recap

### 🌟 Great Work — Here's What You Built!

Today you created a real **win condition** for a Fortnite island. You learned that a **variable** is like a scoreboard that changes during the game, and an **event subscription** is like signing up for automatic alerts. Your Verse code now listens for every elimination, adds to a counter, and — when the counter hits the winning number — activates the **End Game Device** to end the round and crown a winner. That's a complete game loop, and you built it yourself! 🏆

**Sources:**

- /docs/documentation/en-us/uefn/verse-elimination-template-in-unreal-editor-for-fortnite

---

## Lesson 6: Putting It All Together: A Complete Island

**Objectives:**

- Place and connect all key devices (Player Spawn Pad, Item Granter, Timer, Score Manager, and End Game) on one island.
- Write a Verse device that links spawning, scoring, and a win condition together.
- Use @editable variables to connect your Verse code to real devices in UEFN without rewriting code.
- Playtest your finished island and see all systems work together as a complete game.

### 🏆 Let's Build a REAL Game!

You've learned variables. You've learned devices. You've learned events.
Now it's time to **put it all together** — like snapping the last LEGO piece into place!

By the end of this lesson, your island will have:
- A **spawn** (where players start)
- **Scoring** (points for doing things)
- **Rounds** (the game resets and goes again)
- A **win condition** (someone actually wins!)

---

### 🗺️ Think of Your Island Like a Board Game

Imagine a board game. It has rules printed in the box. Those rules say:
- Where each player starts 🟢
- How you earn points 🌟
- How many rounds you play 🔄
- Who wins at the end 🏅

Your Verse code is the **rulebook**. The devices are the **game pieces**.
Verse tells the pieces what to do and when.

---

### 🧩 The Devices You'll Use

Here are the devices for your island. Think of each one as a tool in a toolbox:

| Device | What It Does | Real-Life Analogy |
|---|---|---|
| **Player Spawn Pad** | Where players appear at the start | The "Start" square on a board game |
| **Item Granter** | Gives players a weapon or item | A vending machine that gives free stuff |
| **Timer** | Counts down the clock | A sand timer for a game round |
| **Score Manager** | Tracks each player's points | The scoreboard at a basketball game |
| **End Game** | Ends the round and picks a winner | The buzzer at the end of a game show |
| **Verse Device** | YOUR custom code — the brain! | The game master who runs everything |

---

### 🔌 What is `@editable`?

In Verse, you can write code that **connects to a real device** you placed on your island.
You do this with a special label called **`@editable`**.

Think of `@editable` like a **plug socket** in your code.
You leave the socket empty in the code, then in UEFN you **plug in** whichever device you want.

This is super powerful! You can swap devices without rewriting your code. 🎉

```verse
@editable
MyTimer : timer_device = timer_device{}   # This is an empty socket for a Timer device
```

The line above says: *"I have a Timer. I'll plug in the real one later in UEFN."*

---

### 🔁 What is a Round?

A **round** is one play-through of a game before it resets.
Think of rounds like innings in baseball — when one inning ends, a new one starts.

In UEFN, the **Island Settings** device controls how many rounds you play and how the winner is chosen.
You set this up once, like writing the rules on the box lid.

---

### 🧠 How the Systems Connect

Here's the big picture. Your Verse code is the **hub** in the middle:

```
Player Spawns → Verse Device → Starts Timer
Player Scores → Score Manager → Verse Device checks score
Timer Ends   → Verse Device → Triggers End Game Device
End Game     → Shows winner → New Round Begins
```

Each arrow is an **event**. An event is something that happens in the game —
like a player scoring or the timer hitting zero.

Your Verse code **listens** for these events and **reacts** to them.
It's like a referee watching the field and blowing the whistle at the right moment. 🎺

---

### 🏗️ Setting Up Your Island Settings

Before writing code, set up your Island Settings device:
- **Game Win Condition** → `Most Scores Win`
- **Round Win Condition** → `Score`
- **Join in Progress** → `Spawn`

This tells Fortnite: *"The player with the most points wins!"*

---

### 📦 Building the Scene Step by Step

1. Open UEFN and create a new empty project.
2. Place a **Player Spawn Pad** — this is where players appear.
3. Place an **Item Granter** — give players a weapon so they can play!
4. Place a **Timer** device — set it to count down (e.g., 60 seconds).
5. Place an **End Game** device — this ends the round when triggered.
6. Open **Verse Explorer**, right-click your project, and add a new **Verse Device** file.
7. Name it `island_manager_device`.
8. Write your code (see the worked example below!).
9. Go to **Verse > Build Verse Code** to compile (build = turn your code into something the game can run).
10. Drag your compiled Verse device into the viewport.
11. In the **Details panel**, plug in your Timer and End Game devices into the `@editable` slots.
12. Hit **Launch Session** and play your island! 🎮

### Worked Example

### ✏️ The Complete Island Manager — Verse Code

Here is a short, complete Verse device. It:
1. Waits for the Timer to run out.
2. Then triggers the End Game device to end the round.

Read the comments (the lines starting with `#`) — they explain every single line!

```verse
# These lines let us use Fortnite devices in our code.
# Think of them like opening the right toolbox drawer.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our custom device — the "brain" of our island.
# It extends creative_device, which means it IS a Verse device in UEFN.
island_manager_device := class(creative_device):

    # @editable means we can plug in a real Timer device from UEFN.
    # It's like leaving an empty socket and plugging in the wire later!
    @editable
    RoundTimer : timer_device = timer_device{}

    # @editable for the End Game device — triggers when time is up.
    @editable
    RoundEnder : end_game_device = end_game_device{}

    # OnBegin runs automatically when the game starts.
    # Think of it as the "Game Start" button being pressed.
    OnBegin<override>()<suspends> : void =
        # Start the countdown timer so players can see it ticking.
        RoundTimer.Start()

        # WaitForTimerEnd is a helper function (defined below).
        # We WAIT here until the timer is done before moving on.
        WaitForTimerEnd()

        # Time's up! Now we tell the End Game device to end the round.
        # Activate() is like pressing the "End Round" button on the device.
        RoundEnder.Activate()

    # This function waits until the Timer sends a "Success" event.
    # An event is a signal — like a doorbell ringing when someone arrives.
    WaitForTimerEnd()<suspends> : void =
        # Await means "pause here and wait for this event to happen."
        # SuccessEvent fires when the Timer counts all the way down to zero.
        RoundTimer.SuccessEvent.Await()
```

---

### 🔍 Walkthrough: What Happens When You Play

| Step | What Happens | Which Line Does It |
|---|---|---|
| Game starts | `OnBegin` runs automatically | `OnBegin<override>()` |
| Timer starts ticking | `RoundTimer.Start()` is called | `RoundTimer.Start()` |
| Code waits for timer | `Await()` pauses until time is up | `RoundTimer.SuccessEvent.Await()` |
| Timer hits zero | `SuccessEvent` fires | `RoundTimer.SuccessEvent.Await()` |
| Round ends | `RoundEnder.Activate()` fires | `RoundEnder.Activate()` |
| Winner shown | End Game device shows the winner | Handled by the device! |

### 🔌 Plugging In the Devices in UEFN

After building your code:
1. Click your **island_manager_device** in the viewport.
2. Look at the **Details** panel on the right.
3. You'll see **RoundTimer** and **RoundEnder** slots appear.
4. Click each slot and pick the matching device from your island.
5. Done! Your code is now wired to real devices. ⚡

### Try It Yourself

### 🎯 Your Challenge: Add an Item Granter at Game Start!

Right now, the island starts the timer and ends the round. 
**Your job:** Make the game also give each player a weapon when the game begins!

Here are the steps:

1. Place an **Item Granter** device on your island. Set it to grant a weapon you like.
2. In your Verse code, add a new `@editable` variable for the Item Granter — just like `RoundTimer` and `RoundEnder`.
3. Inside `OnBegin`, **before** `RoundTimer.Start()`, call the Item Granter's grant method to give the item to all players.

**💡 Hint:** The Item Granter device in Verse is called `item_granter_device`.
To grant an item to all players, you can use `GrantToAllPlayers()` on the device.

Here's the skeleton to fill in:

```verse
# Add this with your other @editable variables:
@editable
StarterWeapon : item_granter_device = item_granter_device{}

# Add this inside OnBegin, BEFORE RoundTimer.Start():
StarterWeapon.GrantToAllPlayers()
```

**🌟 Bonus Challenge:** Can you add a second Item Granter that gives players a healing item too?

Playtest your island! You should spawn in, receive your weapon, see the timer count down, and then see the round end with a winner. If all of that happens — YOU DID IT! 🎉

### Quiz

1. What does `@editable` do to a variable in Verse?
   - A. It makes the variable count up automatically during the game.
   - B. It lets you plug in a real UEFN device from the Details panel without changing your code.
   - C. It makes the variable impossible to change while the game is running.
   - D. It gives the variable a random value each time the game starts.

2. What does 'building' (compiling) your Verse code do?
   - A. It places your Verse device automatically on the island.
   - B. It turns your written code into a format the game can actually run.
   - C. It deletes your old code and starts fresh.
   - D. It connects your devices to the internet.

3. In the worked example, what does `RoundTimer.SuccessEvent.Await()` do?
   - A. It immediately ends the game as soon as the game starts.
   - B. It pauses the code and waits until the Timer counts down to zero.
   - C. It gives every player a point when called.
   - D. It starts the timer counting up from zero.

4. Which device is responsible for choosing a winner and ending the round in UEFN?
   - A. The Player Spawn Pad device.
   - B. The Item Granter device.
   - C. The End Game device.
   - D. The HUD Message device.

**Answer key:**

1. B — Correct! `@editable` creates a slot in UEFN's Details panel. You pick which real device fills that slot — no code changes needed. It's like a plug socket waiting for a wire.
2. B — Building (compiling) is like baking a recipe. You've written the instructions, but building actually 'cooks' them so the game engine can use them. Until you build, the device won't appear or work.
3. B — Await() is like pressing 'pause' on a TV remote. The code stops and waits right there until the SuccessEvent fires — which happens when the Timer reaches zero. Then the code continues!
4. C — The End Game device is the buzzer at the end of the game show! When your Verse code calls Activate() on it, the device shows the winner and wraps up the round. The other devices have different jobs.

### Recap

### 🌟 Great Work — You Built a Complete Game!

You connected **spawning**, **scoring**, **a timer**, and a **win condition** all in one island.
The secret glue was your Verse device — it listened for events and told other devices what to do.
`@editable` variables let you wire real devices to your code right from the UEFN Details panel.
Now you have every piece to keep building bigger and more exciting Fortnite islands! 🚀

**Sources:**

- /docs/documentation/en-us/fortnite/first-island-05-spice-up-the-gameplay-with-verse-in-fortnite
- /docs/documentation/en-us/fortnite/verse-parkour-template-in-unreal-editor-for-fortnite

---

*Generated by Verse Cortex on 2026-06-21.*
