Stop the Clock: Building a "Survive the Storm" Challenge with Verse
Tutorial beginner

Stop the Clock: Building a "Survive the Storm" Challenge with Verse

Updated beginner

Stop the Clock: Building a "Survive the Storm" Challenge with Verse

So, you want to build a mode where players have to survive a specific amount of time before the storm closes in? Or maybe you want a "speed run" challenge where finishing early gives you bonus points? In Fortnite Creative, we used to rely on the Timer device and a tangled mess of cables to make this happen. It worked, but it was messy.

Now, with Verse, we can write code that is the timer. We can create a custom "Survival Mode" where the game logic itself counts down the seconds, handles the win/loss conditions, and even calculates your score based on how much time you had left. No more guessing if the cable connected to the right pin. Just clean, executable logic.

What You'll Learn

  • Variables: How to store the "time left" so the game knows when to end.
  • Events & Functions: How to tell the game "start counting now" and "check if time is up."
  • The Scene Graph: Understanding how your code connects to the physical objects (like the player and the storm) in your island.
  • Logic Flow: Building a simple "Start -> Count -> End" loop without getting lost in spaghetti code.

How It Works

Before we write a single line of Verse, let’s look at how a timer works in real life, then map it to Fortnite.

Imagine you’re playing a match. You have a Storm Timer in the top right corner.

  1. The Setup: You set the storm to start in 60 seconds. This is like creating a Variable (a storage box) and putting the number 60 inside it.
  2. The Start: The match begins. The timer starts ticking down. In code, this is a Function (a set of instructions) that runs repeatedly, taking 1 away from our variable every second.
  3. The Event: When the timer hits 0, the storm moves in. This is an Event (a trigger). The game detects the state changed to 0 and fires off a signal: "Close the storm!"
  4. The Result: If you’re still alive, you win. If not, you’re eliminated.

In Verse, we don't just drag-and-drop a device. We define the behavior of the timer. We create a script that says: "When the game starts, set my time variable to 60. Every second, subtract 1. If it hits 0, trigger the storm."

Key Concepts

  • Variable: Think of this as a Loot Box. It holds something that can change. In our case, it holds the TimeRemaining. Right now it’s 60. Later, it’s 59. Then 58.
  • Function: Think of this as a Building Piece. You place it, and it does a specific job. Our Countdown function’s job is to subtract time.
  • Event: Think of this as a Trigger Pad. When a player steps on it, something happens. Our OnTimerEnd event happens when the time variable hits zero.
  • Scene Graph: This is the hierarchy of your island. Imagine a folder structure on your computer. Your Island is the root folder. Inside are folders for "Props," "Players," and "Scripts." Verse lets you reach into these folders and manipulate the objects inside.

Let's Build It

We are going to build a simple "Survival Challenge."

  1. Place a Player Spawn device.
  2. Place a Storm device (set it to "Always Active" or just use the default storm, but we’ll control the start time via code).
  3. Create a new Verse file.

Here is the Verse code. Copy this into your verse file in the UEFN editor.

# This is a comment. It's like leaving a sticky note for yourself.
# The compiler (the game's code checker) ignores these.

# 1. DEFINE THE STRUCTURE
# Think of this as the "Blueprint" for our Timer System.
# It holds all the parts we need.
struct MySurvivalTimer:
    # This is our Variable. It's a "Container" for the time.
    # We start it at 60 seconds.
    TimeRemaining: int = 60
    
    # This is a reference to the Storm Device.
    # We'll connect this in the editor later.
    StormDevice: StormDevice
    
    # This is a reference to the End Game Device.
    # We'll use this to trigger the win/loss state.
    EndGameDevice: EndGameDevice

# 2. DEFINE THE FUNCTIONS (The Actions)
# This function is like a "Stopwatch Tick."
# It runs every second.
func Tick() -> void:
    # Check if we still have time
    if TimeRemaining > 0:
        # Subtract 1 from our Variable (the Loot Box)
        TimeRemaining = TimeRemaining - 1
        
        # Optional: Print to the debug console so we know it's working
        print("Time Left: ", TimeRemaining)
        
        # Schedule this function to run again in 1 second
        # This creates the loop!
        After(1.0, Tick)
    else:
        # Time is up! Trigger the End Game.
        EndGameDevice.End()

# 3. DEFINE THE EVENT (The Trigger)
# This runs when the game starts.
event OnBegin<override>() -> void:
    # Set the initial time
    TimeRemaining = 60
    
    # Start the first tick
    # We call Tick() to start the chain reaction
    Tick()

Walkthrough: What Just Happened?

  1. struct MySurvivalTimer: We created a custom object. In the Scene Graph, this is like creating a new "Actor" or "Device" type. It holds our TimeRemaining (the variable) and links to our StormDevice and EndGameDevice.
  2. func Tick(): This is the core logic. It checks if TimeRemaining is greater than zero. If yes, it subtracts 1. Then, and this is crucial, it calls After(1.0, Tick). This is like setting a Timer Device to "Repeat." It tells the game engine: "Hey, run this Tick function again in exactly 1 second." This creates the countdown loop.
  3. event OnBegin: This is the "Start" button. When the match begins, this function runs once. It resets the time to 60 and kicks off the first Tick().

Connecting It in UEFN

  1. In the Devices panel, search for Storm and place it.
  2. Search for End Game and place it.
  3. In the Verse editor, make sure your file is named correctly and attached to an Actor (usually the World or a custom Actor you created).
  4. Crucial Step: You need to link the devices to your Verse code. In UEFN, you can do this by exposing properties. (Note: For this simple example, we assume the devices are accessible or we are using a simpler pattern where the Verse script is the logic controller. In a full production mode, you would expose StormDevice and EndGameDevice in the struct so you can drag-and-drop the devices from your level into the Verse properties panel).

For a beginner, the easiest way to test this is to use the print statements in the debug console to see the numbers counting down. To make the storm actually start, you would typically bind the EndGameDevice.End() to a device event, or use Verse to manipulate the storm's properties directly if you have access to the Storm API.

Try It Yourself

Challenge: Modify the code to make the timer count UP instead of down. If the player survives for 30 seconds, they win.

Hint:

  1. Change the initial TimeRemaining to 0.
  2. In the Tick() function, change TimeRemaining = TimeRemaining - 1 to TimeRemaining = TimeRemaining + 1.
  3. Change the if condition to check if TimeRemaining >= 30.
  4. If the condition is met, call EndGameDevice.End().

Recap

You just built a custom timer using Verse! You learned that:

  • Variables store changing values (like time left).
  • Functions are reusable blocks of logic (like the countdown tick).
  • Events trigger actions at specific times (like game start).
  • The Scene Graph connects your code to the physical devices in your island.

No more tangled cables. Just clean, logical code that runs exactly when you want it to. Now go make some chaos!

References

  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-timer-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/using-timer-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/using-timed-objective-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/big-rig-device-design-examples-in-fortnite-creative

Verse source files

Turn this into a guided course

Add using-timer-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.

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