Reference Scene Graph compiles

agent & trigger_device: Healing at the Lagoon Dock

Every island adventure needs a place to recover — a sun-drenched dock where weary explorers can top up their health before the next voyage. In Verse, the `agent` type is the universal handle for any player or NPC in your game, and pairing it with `fort_character.Heal()` and a `trigger_device` lets you build exactly that: a glowing lagoon dock that heals anyone who steps onto it, with full control over cooldowns, trigger limits, and timing.

Updated Examples verified on the live UEFN compiler

Overview

The agent type is Verse's fundamental reference to any participant in a Fortnite session — a human player, a bot, or an NPC. On its own agent carries no methods; its power comes from casting it to richer interfaces like fort_character, which exposes the healable interface and its Heal() function.

The trigger_device is the perfect companion: it fires TriggeredEvent whenever a player steps on (or activates) it in the world, handing you the ?agent responsible. From there you unwrap the agent, cast to fort_character, and call Heal() — all in a few lines of Verse.

Reach for this pattern when you need:

  • A healing pad, med-bay, or safe-zone that restores health on contact
  • A checkpoint that tops players up between combat arenas
  • A timed cooldown so the dock can't be spammed
  • A limited-use healing shrine (e.g. only 3 heals per round)

API Reference

agent

Full public surface, resolved verbatim from the live Epic digest (Verse.digest.verse). Inherited members are merged from entity.

agent<native><public> := class<unique><epic_internal>(entity):

trigger_device

Used to relay events to other linked devices.

Full public surface, resolved verbatim from the live Epic digest (Fortnite.digest.verse). Inherited members are merged from trigger_base_device.

trigger_device<public> := class<concrete><final>(trigger_base_device):

Events (subscribe a handler to react):

Event Signature Description
TriggeredEvent TriggeredEvent<public>:listenable(?agent) Signaled when an agent triggers this device. Sends the agent that used this device. Returns false if no agent triggered the action (ex: it was triggered through code).

Methods (call these to make the device act):

Method Signature Description
Trigger Trigger<public>(Agent:agent):void Triggers this device with Agent being passed as the agent that triggered the action. Use an agent reference when this device is setup to require one (for instance, you want to trigger the device only with a particular agent.
Trigger Trigger<public>():void Triggers this device, causing it to activate its TriggeredEvent event.
Enable Enable<public>():void Enables this device.
Disable Disable<public>():void Disables this device.
SetMaxTriggerCount SetMaxTriggerCount<public>(MaxCount:int):void Sets the maximum amount of times this device can trigger. * 0 can be used to indicate no limit on trigger count. * MaxCount is clamped between [0,20].
GetMaxTriggerCount GetMaxTriggerCount<public>()<transacts>:int Gets the maximum amount of times this device can trigger. * 0 indicates no limit on trigger count.
GetTriggerCountRemaining GetTriggerCountRemaining<public>()<transacts>:int Returns the number of times that this device can still be triggered before hitting GetMaxTriggerCount. Returns 0 if GetMaxTriggerCount is unlimited.
SetResetDelay SetResetDelay<public>(Time:float):void Sets the time (in seconds) after triggering, before the device can be triggered again (if MaxTrigger count allows).
GetResetDelay GetResetDelay<public>()<transacts>:float Gets the time (in seconds) before the device can be triggered again (if MaxTrigger count allows).
SetTransmitDelay SetTransmitDelay<public>(Time:float):void Sets the time (in seconds) which must pass after triggering, before this device informs other external devices that it has been triggered.
GetTransmitDelay GetTransmitDelay<public>()<transacts>:float Gets the time (in seconds) which must pass after triggering, before this device informs other external devices that it has been triggered.

Walkthrough

Scenario: A 2D cel-shaded lagoon island. There's a weathered wooden dock jutting into turquoise water. When a player steps onto the dock's trigger pad, they receive a burst of healing (50 HP). The dock then goes on a 5-second cooldown before it can heal again, and it can only be used 10 times total per round before the healing magic runs dry.

using { /Fortnite.com/Game }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }

# Place this device in your UEFN level.
# Wire the DockTrigger to the pressure plate on the dock.
# The device heals any player who steps on the dock.
lagoon_dock_healer := class(creative_device):

    # The trigger pad placed on the dock surface.
    # In UEFN: place a Trigger Device, set it to activate on player contact.
    @editable DockTrigger : trigger_device = trigger_device{}

    # How much health to restore per activation.
    HealAmount : float = 50.0

    # Seconds the dock is locked after each use.
    CooldownSeconds : float = 5.0

    # Maximum times the dock can heal before it goes dark for the round.
    MaxUses : int = 10

    # Tracks whether the dock is currently cooling down.
    var IsOnCooldown : logic = false

    OnBegin<override>()<suspends>:void =
        # Configure the trigger: max 10 activations, 5-second reset delay.
        # SetMaxTriggerCount clamps between 0 and 20; 0 = unlimited.
        DockTrigger.SetMaxTriggerCount(MaxUses)
        DockTrigger.SetResetDelay(CooldownSeconds)

        # Subscribe: every time a player steps on the dock, call OnDockTriggered.
        DockTrigger.TriggeredEvent.Subscribe(OnDockTriggered)

        # Keep the coroutine alive so subscriptions stay active.
        Sleep(Inf)

    # Called by TriggeredEvent — receives ?agent (optional agent).
    OnDockTriggered(MaybeAgent : ?agent) : void =
        # The lagoon dock only heals real players, not code-triggered activations.
        if (A := MaybeAgent?):
            # Cast agent -> fort_character to access the healable interface.
            if (Character := A.GetFortCharacter[]):
                # Heal the player! healing_args carries the amount.
                Character.Heal(healing_args{Amount := HealAmount})```

**Line-by-line explanation:**

| Lines | What's happening |
|---|---|
| `@editable DockTrigger` | Exposes the trigger_device slot in the UEFN Details panel so you can wire in the dock's pressure plate. |
| `DockTrigger.SetMaxTriggerCount(MaxUses)` | Tells the trigger to stop firing after 10 uses  the dock's healing magic runs out. |
| `DockTrigger.SetResetDelay(CooldownSeconds)` | After each heal, the trigger locks for 5 seconds — no spam-healing allowed. |
| `DockTrigger.TriggeredEvent.Subscribe(OnDockTriggered)` | Registers our handler; Verse calls it every time the trigger fires. |
| `Sleep(Inf)` | Keeps `OnBegin` suspended forever so the subscription stays live. |
| `if (A := MaybeAgent?)` | Safely unwraps the `?agent` — skips the heal if no real player triggered it. |
| `A.GetFortCharacter[]` | Failable cast from `agent` to `fort_character`; fails gracefully if the agent isn't a Fortnite character. |
| `Character.Heal(healing_args{Amount := HealAmount})` | Applies 50 HP of healing through the `healable` interface. |

## Common patterns

### Pattern 1 — Query the dock's remaining uses and disable it when exhausted

Use `GetTriggerCountRemaining` and `GetMaxTriggerCount` to display (or act on) how many heals are left, then call `Disable()` for a dramatic "dock goes dark" moment.

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

# Monitors the dock trigger and disables it when all charges are spent.
dock_charge_monitor := class(creative_device):

    @editable DockTrigger : trigger_device = trigger_device{}

    # A secondary trigger fires a visual effect when the dock goes dark.
    @editable DarkEffectTrigger : trigger_device = trigger_device{}

    OnBegin<override>()<suspends>:void =
        DockTrigger.SetMaxTriggerCount(5)
        DockTrigger.TriggeredEvent.Subscribe(OnDockUsed)
        Sleep(Inf)

    OnDockUsed(MaybeAgent : ?agent) : void =
        # Check remaining charges after each use.
        Remaining := DockTrigger.GetTriggerCountRemaining()
        Max := DockTrigger.GetMaxTriggerCount()

        if (Remaining = 0 and Max > 0):
            # All charges spent — disable the dock and fire the "dark" effect.
            DockTrigger.Disable()
            # Trigger the darkness VFX device with no specific agent.
            DarkEffectTrigger.Trigger()

Pattern 2 — A pirate ship cannon resets the dock trigger with a transmit delay

When a cannon fires (simulated by calling Trigger(Agent)), the dock reactivates after a transmit delay — the cannonball "recharges" the healing crystal.

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

# A cannon on the pirate ship recharges the healing dock.
# The transmit delay represents the cannonball travel time.
cannon_recharge_dock := class(creative_device):

    # The dock trigger that heals players.
    @editable DockTrigger : trigger_device = trigger_device{}

    # A separate trigger representing the cannon firing.
    @editable CannonTrigger : trigger_device = trigger_device{}

    # Seconds of "cannonball travel" before the dock reactivates.
    CannonballTravelSeconds : float = 3.0

    OnBegin<override>()<suspends>:void =
        # The dock starts disabled — it needs a cannon shot to power it.
        DockTrigger.Disable()

        # The cannon trigger fires with a 3-second transmit delay.
        # External devices (like the dock) receive the signal after the delay.
        CannonTrigger.SetTransmitDelay(CannonballTravelSeconds)

        CannonTrigger.TriggeredEvent.Subscribe(OnCannonFired)
        Sleep(Inf)

    OnCannonFired(MaybeAgent : ?agent) : void =
        if (A := MaybeAgent?):
            # Re-enable the dock and reset its charges for this player's round.
            DockTrigger.Enable()
            DockTrigger.SetMaxTriggerCount(3)
            # Trigger the dock directly for the agent who fired the cannon
            # — they get an instant heal as a reward for firing.
            if (Character := A.GetFortCharacter[]):
                Character.Heal(healing_args{Amount := 25.0})

Pattern 3 — Timed heal-over-time loop at the lagoon shore

Instead of a single burst, the player stands on the shore trigger and receives small heals every second for 5 seconds — a regeneration zone.

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

# Standing on the lagoon shore regenerates health over time.
lagoon_regen_zone := class(creative_device):

    @editable ShoreTrigger : trigger_device = trigger_device{}

    # Heal this much per tick.
    HealPerTick : float = 10.0

    # Number of heal ticks.
    TickCount : int = 5

    # Seconds between each tick.
    TickInterval : float = 1.0

    OnBegin<override>()<suspends>:void =
        # Unlimited triggers (0 = no limit), 2-second cooldown between entries.
        ShoreTrigger.SetMaxTriggerCount(0)
        ShoreTrigger.SetResetDelay(2.0)
        ShoreTrigger.TriggeredEvent.Subscribe(OnShoreEntered)
        Sleep(Inf)

    OnShoreEntered(MaybeAgent : ?agent) : void =
        if (A := MaybeAgent?):
            # Spawn a concurrent heal-over-time task for this agent.
            spawn { HealOverTime(A) }

    # Heals the agent in small increments over several seconds.
    HealOverTime(A : agent)<suspends> : void =
        if (Character := A.GetFortCharacter[]):
            var TicksLeft : int = TickCount
            loop:
                if (TicksLeft <= 0):
                    break
                Character.Heal(healing_args{Amount := HealPerTick})
                set TicksLeft = TicksLeft - 1
                Sleep(TickInterval)

Gotchas

1. ?agent must be unwrapped before use

TriggeredEvent sends a ?agent (optional agent), not a plain agent. Always unwrap it:

# WRONG — won't compile
OnTriggered(MaybeAgent : ?agent) : void =
    MaybeAgent.GetFortCharacter[]  # ?agent has no GetFortCharacter

# CORRECT
OnTriggered(MaybeAgent : ?agent) : void =
    if (A := MaybeAgent?):          # unwrap first
        if (Character := A.GetFortCharacter[]):
            Character.Heal(healing_args{Amount := 50.0})

When the trigger fires via code (e.g. DockTrigger.Trigger() with no agent), MaybeAgent is false — the if block simply skips, which is the safe behaviour.

2. GetFortCharacter[] is failable — always use if

GetFortCharacter[] has the <decides> effect, meaning it can fail (e.g. for non-Fortnite agents). Wrap it in if or it won't compile.

3. SetMaxTriggerCount clamps to [0, 20]

Passing a value above 20 silently clamps to 20. Use 0 for truly unlimited triggers. Plan your heal economy around this ceiling.

4. SetResetDelay vs SetTransmitDelay — know the difference

  • SetResetDelay: how long before the trigger can fire again (player-facing cooldown).
  • SetTransmitDelay: how long before the trigger notifies linked external devices (useful for sequenced effects, not for the cooldown itself). Mixing these up leads to confusing timing bugs.

5. Sleep(Inf) is required in OnBegin

Without Sleep(Inf) at the end of OnBegin, the coroutine exits and your Subscribe handlers may stop receiving events. Always park the coroutine alive.

6. healing_args is a struct, not a function call

Construct it with named fields: healing_args{Amount := 50.0}. Passing a bare float won't compile.

7. Heal() respects max health

Heal() will never push a player above their maximum health. If you want to check current health before healing, use Character.GetHealth() to avoid wasting charges on a full-health player.

Guides & scripts that use agent

Step-by-step tutorials that put this object to work.

Build your own lesson with agent

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 →