The Game Loop: How to Stop Your Island From Being a Ghost Town
Tutorial beginner

The Game Loop: How to Stop Your Island From Being a Ghost Town

Updated beginner

The Game Loop: How to Stop Your Island From Being a Ghost Town

You’ve built the map. You’ve placed the props. You’ve rigged the traps. But when you hit "Play," nothing happens. The players spawn, stand around awkwardly like they’re waiting for the bus, and the game just... sits there. No rounds. No winners. No drama.

That’s because you’re missing the Game Loop.

Think of the Game Loop as the heartbeat of your island. In Fortnite, the Battle Bus flies, the storm closes, and the match ends. In UEFN, you have to build that rhythm yourself. Without a loop, your island is just a static scene with no rules, no start, and no finish. Today, we’re going to wire up the central nervous system of your Prop Hunt map using Verse. We’ll create a system that detects when players join, assigns them to teams (Hunters vs. Props), starts a timer, and knows exactly when the round is over.

No more awkward silences. Let’s make your island actually play like a game.

What You'll Learn

  • The Game Loop Concept: Why your island needs a "start," "play," and "end" state.
  • State Management: How to track who is a Hunter and who is a Prop using variables.
  • Event Subscriptions: How to make your code "listen" for when players join or when a timer hits zero.
  • Round Management: Writing the Verse logic to reset the board and start the chaos.

How It Works

The Game Loop: It’s Like a New Season

Imagine Fortnite without seasons. You’d just spawn in, play one match, and then... nothing. The game would end. But Fortnite has a loop. It resets, rebalances, and starts fresh every few months.

In UEFN, the Game Loop is the code that runs continuously to manage these cycles. It doesn’t run during the action (like shooting); it runs between actions. It checks:

  1. Start: Are players here? Assign teams.
  2. Play: Is the timer running? Are props hiding?
  3. End: Did everyone die? Did time run out? If yes, reset the board.

Variables: The Scoreboard

You know how your score changes when you get an elimination? That’s a Variable. In programming, a variable is a container that holds a value that can change.

  • Before: Score = 0
  • After Elimination: Score = 100

In our Prop Hunt loop, we’ll use variables to track the Round State. Is the round Waiting? Is it Playing? Is it Finished? This is like the Storm Timer: it starts at 0, counts down, and when it hits 0, something changes (the storm closes).

Event Subscriptions: The Trigger Pad

Remember how you place a Trigger Pad and connect it to a Prop Mover? The Pad subscribes to the Mover. When the Pad is triggered, the Mover moves.

In Verse, we do the same thing, but with code. We write a function (a block of code) and "subscribe" it to an event.

  • Event: PlayerJoined
  • Subscribed Function: AssignTeam

When a player joins, the game automatically calls AssignTeam. You don’t have to ask; the game tells your code, "Hey, someone new is here! Do your thing!"

Let's Build It

We’re going to build the core logic for a Prop Hunt round. This script will:

  1. Listen for players joining.
  2. Randomly assign them to Hunters or Props.
  3. Start the round timer.
  4. Detect when the round ends.

Copy this into a Verse file in your project.

# Import the necessary UEFN libraries
using /Fortnite.com/Devices
using /Verse.org/Simulation
using /Engine/Systems

# This is our main device. Think of it as the "Brain" of the island.
# It sits in the world and holds all the logic.
script class PropHuntBrain extends Device:

    # --- VARIABLES (The State) ---
    # These are like the settings on your controller. They define how the game behaves.
    HunterCount: int = 2       # How many hunters per round?
    PropCount: int = 8         # How many props per round?
    RoundTime: float = 120.0   # 120 seconds per round (like the storm timer)

    # --- EVENTS (The Triggers) ---
    # We "subscribe" to these events. When they happen, our functions run.
    # OnPlayerJoined is called automatically when a player enters the game.
    OnPlayerJoined: Event<Player> = Event()

    # OnRoundStart is a custom event we'll trigger when the round begins.
    OnRoundStart: Event = Event()

    # --- FUNCTIONS (The Actions) ---

    # This function runs when the Brain first initializes.
    # It's like pressing "Start Game" in the menu.
    Initialize() -> void:
        # Subscribe to the player join event.
        # Whenever a player joins, call the 'HandlePlayerJoin' function.
        OnPlayerJoined.Subscribe(HandlePlayerJoin)
        
        # Print a message to the debug log (the "chat" for developers)
        Print("Brain Initialized. Waiting for players...")

    # This function handles what happens when a new player joins.
    HandlePlayerJoin(Player: Player) -> void:
        # In a full game, you'd check if teams are full here.
        # For now, let's just log it.
        Print($"{Player.GetPlayerName()} has joined the lobby.")

        # Check if we have enough players to start (e.g., 2 hunters + 8 props = 10 players)
        # Note: In a real build, you'd track active player counts.
        # If enough players are here, trigger the start!
        # For this demo, we'll assume the map designer triggers the start manually
        # or we add a simple check later. Let's just print for now.
        
    # This is the core of the Game Loop: Starting the Round
    StartRound() -> void:
        Print("Round Starting! Go hide or go hunt!")
        
        # Trigger our custom event so other devices (like timers) can listen
        OnRoundStart.Trigger()
        
        # Here is where you would normally:
        # 1. Teleport all players to spawn points.
        # 2. Give Hunters weapons.
        # 3. Randomly assign Props to hide spots.
        # 4. Start the RoundTime countdown.

    # This function ends the round.
    EndRound() -> void:
        Print("Round Over! Resetting board...")
        # Here you would:
        # 1. Show the winner screen.
        # 2. Clear all props/hunters.
        # 3. Wait a few seconds, then call StartRound() again.

Walkthrough: What Just Happened?

  1. script class PropHuntBrain: This creates a new "Device" in UEFN. You can drag this into your level like any other device. It’s the container for all our code.
  2. OnPlayerJoined.Subscribe(HandlePlayerJoin): This is the magic line. We are telling the game: "Hey, every time a player joins, run the HandlePlayerJoin function." This is the Event Subscription.
  3. Initialize(): This function runs once when the game starts. It sets up the subscriptions. Think of it as loading your save file.
  4. StartRound(): This is the heart of the loop. When called, it announces the start and triggers the OnRoundStart event. Other devices (like a Round Settings device) can listen to this event to know when to start their timers.

Try It Yourself

You’ve got the brain. Now give it some muscles.

Challenge: Add a RoundTimer device to your level. Connect its OnTimerFinished event to a Verse function in your PropHuntBrain that calls EndRound().

Hint: You’ll need to create a new function called OnRoundTimerFinished() and subscribe it to the timer’s event inside your Initialize() function. Remember, the timer needs to be started when StartRound() is called!

Recap

  • Game Loop: The cycle of Start -> Play -> End that keeps your game alive.
  • Variables: Containers for changing values (like team counts or timer settings).
  • Events & Subscriptions: The way your code reacts to game moments (like a player joining or a timer finishing).
  • Verse Script: The brain that ties it all together, replacing the need for a million connected devices.

You now have the foundation for a dynamic, playable Prop Hunt map. No more static scenes. Your island is alive. Now go make it chaotic.

References

  • https://dev.epicgames.com/documentation/en-us/fortnite/prop-hunt-05-game-loop-and-round-management-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/fortnite/prop-hunt-template-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/uefn/verse-prop-hunt-template-5-game-loop-and-round-management-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/fortnite/prop-hunt-10-customizing-the-gameplay-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/uefn/verse-prop-hunt-template-in-unreal-editor-for-fortnite

Verse source files

Turn this into a guided course

Add prop-hunt-05-game-loop-and-round-management-in-unreal-editor-for-fortnite 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.

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.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in