Reference Verse compiles

Respawn With Delay: Vanishing Dock Platforms in Verse

Ever wanted a rickety dock where planks snap away under a player's feet and wash back up seconds later? The **Respawn-with-Delay** pattern combines the `Trigger` device (which removes a tile on contact) with `Sleep` and `GetRandomFloat` to make that plank reappear after a randomised pause — no Blueprint required. It's one of the most satisfying "game feel" tricks in UEFN, and once you understand it you'll use it everywhere: lava floors, crumbling cliffs, timed bridges over a cove.

Updated Examples verified on the live UEFN compiler
Watch the Knotrespawn_with_delay in ~90 seconds.

Overview

The respawn-with-delay pattern is not a single named device — it is a Verse-coded behaviour you attach to one or more Trigger devices (the patchwork tile variant that removes itself when stepped on). The core loop is:

  1. Player steps on a dock plank → TriggeredEvent fires.
  2. Verse records who stepped on it, waits a configurable number of seconds (Sleep).
  3. The plank reappears by calling Trigger again on a reset trigger, or simply by the island re-enabling the tile — giving the illusion of a plank washing back into place.

Use this pattern whenever you need timed environmental hazards: disappearing stepping-stones across a cove, crumbling clifftop ledges, or a dock that slowly collapses as players race across it.

API Reference

(API surface could not be resolved for this device.)

Walkthrough

Scenario: The Sunny Cove Dock

Your 2D cel-shaded island has a wooden dock stretching out over a bright turquoise cove. Five planks are each backed by a Trigger device (the Patchwork Trigger — the one that removes its associated tile on activation). When a player steps on a plank it vanishes; after a random delay between 2 and 5 seconds it snaps back into place.

Each plank needs its own Trigger device placed in the UEFN level and wired to this Verse device via @editable fields.

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

# Attach this creative_device to a Verse Device actor in the level.
# Wire each PlankTrigger field to a Patchwork Trigger placed under a dock plank.
cove_dock_device := class(creative_device):

    # --- Editable fields: wire these to Patchwork Trigger devices in UEFN ---
    @editable
    PlankA : trigger_device = trigger_device{}

    @editable
    PlankB : trigger_device = trigger_device{}

    @editable
    PlankC : trigger_device = trigger_device{}

    # How many seconds (minimum) before a plank reappears.
    @editable
    MinRespawnDelay : float = 2.0

    # How many seconds (maximum) before a plank reappears.
    @editable
    MaxRespawnDelay : float = 5.0

    # Called once when the island starts.
    OnBegin<override>()<suspends> : void =
        # Subscribe each plank's TriggeredEvent to our handler.
        # The handler receives the agent who stepped on the plank.
        PlankA.TriggeredEvent.Subscribe(OnPlankATriggered)
        PlankB.TriggeredEvent.Subscribe(OnPlankBTriggered)
        PlankC.TriggeredEvent.Subscribe(OnPlankCTriggered)

    # --- Per-plank handlers (one per Trigger so we know WHICH plank to respawn) ---

    OnPlankATriggered(Agent : ?agent) : void =
        # Spin up an async task so the handler returns immediately
        # and the plank respawn runs concurrently.
        spawn { RespawnPlank(PlankA) }

    OnPlankBTriggered(Agent : ?agent) : void =
        spawn { RespawnPlank(PlankB) }

    OnPlankCTriggered(Agent : ?agent) : void =
        spawn { RespawnPlank(PlankC) }

    # Waits a random delay then re-triggers the plank tile so it reappears.
    # The Patchwork Trigger's Trigger() call removes the tile;
    # calling Enable() restores it — but since the tile was already removed
    # by the player stepping on it, we wait and then re-enable the device
    # so the next player step will trigger it again.
    RespawnPlank(Plank : trigger_device)<suspends> : void =
        # Pick a random delay between Min and Max seconds.
        Delay : float = GetRandomFloat(MinRespawnDelay, MaxRespawnDelay)
        # Suspend this coroutine for that many seconds.
        # The game keeps running; other planks can fall independently.
        Sleep(Delay)
        # Re-enable the trigger so the tile is restored and
        # the plank can be stepped on (and fall) again.
        Plank.Enable()```

### Line-by-line explanation

| Lines | What's happening |
|---|---|
| `@editable PlankA : trigger_device` | Exposes the Patchwork Trigger to the UEFN Details panel so you can wire it to a real placed device. Without `@editable` the field is just a default empty device and nothing happens. |
| `PlankA.TriggeredEvent.Subscribe(OnPlankATriggered)` | Registers `OnPlankATriggered` as the callback. Every time a player steps on Plank A, Verse calls this method with the stepping `agent`. |
| `spawn { RespawnPlank(PlankA) }` | `spawn` launches `RespawnPlank` as a concurrent async task. The event handler returns immediately (it must — event handlers are synchronous), while the respawn countdown runs in the background. |
| `GetRandomFloat(MinRespawnDelay, MaxRespawnDelay)` | Returns a random `float` in the editable range. Each plank gets its own independent random delay, so they don't all reappear at once. |
| `Sleep(Delay)` | Suspends *only this coroutine* for `Delay` seconds. The rest of the island  other planks, other players  keeps running normally. |
| `Plank.Enable()` | Restores the Patchwork Trigger (and its associated tile) so the plank is solid again and ready to fall next time. |

## Common patterns

### Pattern 1 — Instant-snap plank (zero random, fixed delay)

Sometimes you want a perfectly predictable rhythm  like a metronome dock where every plank reappears after exactly 3 seconds. Remove the randomness:

```verse
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Devices/Patchwork }

metronome_dock_device := class(creative_device):

    @editable
    TimedPlank : trigger_device = trigger_device{}

    @editable
    FixedDelay : float = 3.0

    OnBegin<override>()<suspends> : void =
        TimedPlank.TriggeredEvent.Subscribe(OnTimedPlankTriggered)

    OnTimedPlankTriggered(Agent : agent) : void =
        spawn { FixedRespawn() }

    FixedRespawn()<suspends> : void =
        # Sleep with a fixed duration — no randomness.
        Sleep(FixedDelay)
        TimedPlank.Enable()

Pattern 2 — Chain reaction: one plank triggers the next

For a dramatic collapsing dock effect, stepping on Plank A starts a cascade: after a short delay Plank B is manually triggered (removed) by Verse itself, then Plank C, giving the feel of a wave of collapse rolling down the dock.

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

cascade_dock_device := class(creative_device):

    @editable
    PlankFirst  : trigger_device = trigger_device{}

    @editable
    PlankSecond : trigger_device = trigger_device{}

    @editable
    PlankThird  : trigger_device = trigger_device{}

    # Gap between each plank falling in the cascade (seconds).
    @editable
    CascadeGap : float = 0.4

    OnBegin<override>()<suspends> : void =
        PlankFirst.TriggeredEvent.Subscribe(OnFirstPlankTriggered)

    OnFirstPlankTriggered(Agent : agent) : void =
        spawn { RunCascade() }

    RunCascade()<suspends> : void =
        # The first plank already fell (player stepped on it).
        # Now collapse the next two in sequence.
        Sleep(CascadeGap)
        # Trigger() removes the tile immediately — no player needed.
        PlankSecond.Trigger()

        Sleep(CascadeGap)
        PlankThird.Trigger()

        # After a longer pause, restore all three planks.
        Sleep(3.0)
        PlankFirst.Enable()
        PlankSecond.Enable()
        PlankThird.Enable()

Pattern 3 — Tracking which player fell through

Want to award a penalty point to the player who fell? The TriggeredEvent sends the agent who stepped on the tile. Wire in a score_manager_device to deduct a point:

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

penalty_dock_device := class(creative_device):

    @editable
    PenaltyPlank : trigger_device = trigger_device{}

    @editable
    ScoreManager : score_manager_device = score_manager_device{}

    @editable
    MinRespawn : float = 2.0

    @editable
    MaxRespawn : float = 4.0

    OnBegin<override>()<suspends> : void =
        PenaltyPlank.TriggeredEvent.Subscribe(OnPenaltyPlankTriggered)

    OnPenaltyPlankTriggered(Agent : agent) : void =
        # Deduct a point from the agent who fell.
        # score_manager_device.Activate(Agent) grants points;
        # configure the device in UEFN to award a negative value.
        ScoreManager.Activate(Agent)
        spawn { RespawnAfterDelay() }

    RespawnAfterDelay()<suspends> : void =
        Delay : float = GetRandomFloat(MinRespawn, MaxRespawn)
        Sleep(Delay)
        PenaltyPlank.Enable()

Gotchas

1. You MUST use @editable — bare device fields do nothing

A field declared as PlankA : trigger_device = trigger_device{} without @editable creates a default empty device that is not connected to anything in the level. Always mark device fields @editable and wire them in the UEFN Details panel.

2. Event handlers must be synchronous — use spawn for async work

TriggeredEvent.Subscribe expects a handler with signature (Agent : agent) : void. That handler cannot be <suspends>. If you call Sleep directly inside it the compiler will reject it. Always spawn { MyAsyncFunction() } from inside the handler.

3. Sleep(0.0) yields to the next tick, not instantly

Passing 0.0 to Sleep does not mean "no delay" — it means "wait until the next simulation tick". If you truly want no delay before re-enabling, call Plank.Enable() directly without a Sleep (though this usually looks jarring to players).

4. GetRandomFloat returns a float — don't mix with int

Verse does not auto-convert between int and float. If you store MinRespawnDelay as an int and pass it to GetRandomFloat, the compiler will error. Keep delay fields as float.

5. Trigger() vs Enable() — know the difference

  • Trigger() on a Patchwork Trigger removes the tile immediately (as if a player stepped on it). Use this for the cascade pattern.
  • Enable() restores the device (and its tile) to its active state. Use this to make the plank reappear after the delay.
  • Calling Trigger() when the tile is already gone has no visible effect but does not error.

6. Multiple players on the same plank can stack coroutines

If two players step on the same plank in the same tick, two spawn { RespawnPlank(...) } calls fire, and the plank will be Enable()d twice. This is harmless (enabling an already-enabled device is a no-op) but worth knowing if you add state tracking.

7. TriggeredEvent sends agent, not ?agent

The Patchwork TriggeredEvent is typed listenable(agent) — the handler receives a non-optional agent directly. You do not need to unwrap it with if (A := Agent?). (Contrast with some other events that send ?agent, which do require unwrapping.)

Build your own lesson with respawn_with_delay

Generate a personalized, step-by-step lesson plan built around this object — grounded in this exact reference and our compile-verified knowledge base.

Build a lesson →