The Ghost Platform: Make Disappearing Traps Actually Work
Tutorial beginner compiles

The Ghost Platform: Make Disappearing Traps Actually Work

Updated beginner Code verified

The Ghost Platform: Make Disappearing Traps Actually Work

Ever built a disappearing platform only to have it vanish the millisecond a player touches it, leaving them to plummet into the pit? Or worse, have it stay visible forever, ruining the suspense? It’s not your building skills; it’s your timing.

In this tutorial, we’re going to build a "Ghost Platform." It’s a trap that lets the player land safely, waits just long enough for them to breathe (or loot the chest underneath), and then vanishes into the void. We’ll use Verse to control the exact delay, turning a static prop into a dynamic, chaotic hazard.

What You'll Learn

  • Variables: How to store a number (like a timer) so you can change it later without rewriting code.
  • Events: How to listen for a specific moment (a player landing) and react to it.
  • Suspension (<suspends>): How to make the code "pause" and wait in real-time without freezing the whole game.
  • Scene Graph Basics: Understanding how your code connects to the 3D objects in your world.

How It Works

Imagine you’re playing a custom map. You jump onto a stone slab. If it disappears instantly, you die. If it stays forever, it’s just a floor. You want that sweet spot where it holds for 2 seconds, then poof.

In Fortnite, we usually use Devices (like Trigger Zones or Prop Movers) to do this. But Devices are rigid. They do exactly what you tell them in the editor, and if you want to change the timing for one specific platform, you have to edit the device itself.

Verse gives you more control. Think of a Variable as a loot drop. It’s a container that holds a value. In this case, our variable is a float (a number with decimals) called DisappearDelay. You set this value once in the editor (like picking your skin), and the code uses it to decide how long to wait.

Here is the flow:

  1. Listen: The code waits for a "Triggered Event." This is like a sensor. When a player steps on the platform, the sensor trips.
  2. Wait: The code pauses for the amount of time stored in our DisappearDelay variable. This is where the <suspends> keyword comes in. It tells the game, "Pause this specific action, but let everything else keep running."
  3. Disappear: The platform hides.
  4. Reset: The platform reappears after a random delay, ready to trick someone else.

Let's Build It

We need two things in your UEFN (Unreal Editor for Fortnite) scene:

  1. A Static Mesh (the platform itself). Let’s call it GhostPlatform.
  2. A Trigger Zone (the sensor). Place it exactly where the platform is. Let’s call it TouchSensor.

Now, let’s write the Verse script. This script will attach to the Trigger Zone.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Random }

# We are creating a device that listens for players.
# 'creative_device' is the base class for all UEFN devices.
# Think of it as the "container" for our logic.
platform_trap := class(creative_device):
    # --- VARIABLES (The Loot Drops) ---
    
    # This is the platform prop we want to hide.
    # @editable means you can change this in the editor's Details panel.
    @editable
    GhostPlatform: creative_prop = creative_prop{}
    
    # This is the trigger zone we are attaching to.
    @editable
    TouchSensor: trigger_device = trigger_device{}
    
    # The big one: How many seconds to wait after landing?
    # We default to 2.0 seconds. Change this in the editor!
    @editable
    DisappearDelay: float = 2.0
    
    # --- THE BRAIN (OnBegin) ---
    
    # This function runs once when the game starts.
    # <suspends> means this function can pause and wait.
    OnBegin<override>()<suspends>: void =
        # Subscribe to the TriggeredEvent.
        # This is like setting up a security camera.
        # Whenever the TouchSensor is tripped, run the 'HandleTouch' function.
        TouchSensor.TriggeredEvent.Subscribe(OnTouch)
        
        # We don't return anything, so it's 'void'.
        # The code here just sets up the listener and then stops.
        # The actual waiting happens inside HandleTouch.

    # This function runs EVERY TIME someone lands on the platform.
    OnTouch(Agent: ?agent): void =
        spawn { HandleTouch() }

    HandleTouch()<suspends>: void =
        # 1. WAIT!
        # Pause the execution of THIS specific instance.
        # The game doesn't freeze; it just waits 'DisappearDelay' seconds.
        Sleep(DisappearDelay)
        
        # 2. VANISH
        # Hide the mesh. It's still there in the code, but invisible.
        GhostPlatform.Hide()
        
        # 3. REAPPEAR (The Reset)
        # Wait a random amount of time between 1 and 3 seconds.
        # This makes the trap feel alive and unpredictable.
        RandomWait := GetRandomFloat(1.0, 3.0)
        Sleep(RandomWait)
        
        # Show the platform again for the next victim.
        GhostPlatform.Show()```

### Walkthrough: What Just Happened?

1.  **`class(creative_device)`**: This defines our object. In the Scene Graph, this is an **Entity**. Its a container that holds data (variables) and behavior (functions).
2.  **`@editable DisappearDelay: float = 2.0`**: This is your variable. By marking it `@editable`, you can go into the UEFN editor, select this device, and change `2.0` to `0.5` for a fast trap or `5.0` for a slow, suspenseful one. No code changes needed.
3.  **`Subscribe(HandleTouch)`**: This is the event listener. Its like setting a tripwire. Nothing happens until someone crosses it.
4.  **`Sleep(DisappearDelay)`**: This is the magic line. Without `<suspends>` on the function signature, `Sleep` would pause the *entire game*. With it, only this specific trap pauses. Its like pausing a video game on one console while the others keep running.
5.  **`Hide()` / `Show()`**: These are methods (actions) on the `static_mesh` object. They toggle visibility.

## Try It Yourself

Youve got the basics, but lets add some chaos.

**Challenge:** Modify the code so the platform doesnt just disappear, but also plays a sound effect when it vanishes.

*Hint:* Youll need to add another `@editable` variable for a `sound_cue` (or `audio_cue`), and then call a method on it inside the `HandleTouch` function before the `Sleep` command. Check the documentation for how to play a sound from a device.

## Recap

You just built a dynamic trap using Verse. You learned that **variables** store settings (like delay time), **events** listen for player actions (like landing), and **suspension** (`<suspends>`) allows your code to wait in real-time without freezing the game. By connecting these concepts to the Scene Graph (the platform and the trigger), youve turned a static prop into an interactive, timing-based hazard.

## References

- https://dev.epicgames.com/documentation/en-us/fortnite/synchronized-disappearing-platforms-using-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/uefn/synchronized-disappearing-platforms-using-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/disappearing-platform-on-touch-using-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/uefn/disappearing-platform-on-touch-using-verse-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/community/snippets/Dde8/fortnite-waiting-for-players-countdown-device

Verse source files

Turn this into a guided course

Add How long to wait in seconds after platforms start appearing 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