Reference Verse compiles

GetHealth / SetHealth: Real-Time HP Control in Verse

Every great Fortnite island moment — the pirate who limps to the dock at 10 HP, the lagoon trap that resets a player to full before the final wave — lives or dies on precise health control. Verse exposes `GetHealth` and `SetHealth` directly on `fort_character`, letting you read, clamp, restore, or drain HP in a single line of transactional code. This article shows you exactly how to wire those calls into a real island scenario.

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

Overview

The healthful interface is implemented by fort_character and gives you two surgical tools:

  • GetHealth() — reads the character's current HP as a float (always between 0.0 and GetMaxHealth()).
  • SetHealth(Health:float) — writes a new HP value, clamped to [1.0, GetMaxHealth()]. It cannot set HP to 0.0; use damageable.Damage to eliminate a character instead.

Both calls carry the <transacts> effect, meaning they participate in Verse's rollback-safe transaction system — safe to call from event handlers and async contexts alike.

When to reach for it:

  • Refill a player to full HP when they enter a safe zone (lagoon shrine, medic tent).
  • Read HP to gate a puzzle — only players below 50 HP may open the vault.
  • Build a "last stand" mechanic that sets HP to exactly 1 before a boss fight.
  • Sync a UI health bar by polling GetHealth() on a tick.

API Reference

player

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

player<native><public> := class<unique><persistent><module_scoped_var_weak_map_key><epic_internal>(agent):

Walkthrough

Scenario — The Pirate Cove Healing Shrine

A glowing shrine sits on a sun-drenched dock. When a player steps on the trigger plate:

  1. Their current HP is read and printed to the log.
  2. If they are below 50 HP they are fully restored — the shrine "activates".
  3. If they are already healthy the shrine does nothing and tells them so via a HUD message.

This single example calls both GetHealth and SetHealth.

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

# ── Pirate Cove Healing Shrine ──────────────────────────────────────────────
# Place a trigger_device on your dock and wire it to Shrineplate below.
# When a wounded player (< 50 HP) steps on the plate their HP is set to max.

pirate_cove_shrine := class(creative_device):

    # Wire this to the trigger plate on the dock in the UEFN Details panel.
    @editable
    ShrinePlate : trigger_device = trigger_device{}

    # ── Lifecycle ────────────────────────────────────────────────────────────
    OnBegin<override>()<suspends> : void =
        # Subscribe: every time a player steps on the plate, call OnPlayerEntered.
        ShrinePlate.TriggeredEvent.Subscribe(OnPlayerEntered)

    # ── Event handler ────────────────────────────────────────────────────────
    # trigger_device.TriggeredEvent sends ?agent, so the param is optional.
    OnPlayerEntered(MaybeAgent : ?agent) : void =
        # 1. Unwrap the optional agent — bail out if no agent was sent.
        if (A := MaybeAgent?):
            # 2. Cast agent → player → fort_character (all failable, so one if-chain).
            if (P := player[A]):
                if (FC := P.GetFortCharacter[]):
                    # 3. Read current health.
                    CurrentHP : float = FC.GetHealth()
                    Print("Shrine touched — player HP: {CurrentHP}")

                    # 4. Gate: only heal players who are wounded.
                    if (CurrentHP < 50.0):
                        # 5. Restore to full (SetHealth clamps to MaxHealth automatically).
                        FC.SetHealth(FC.GetMaxHealth())
                        Print("Shrine activated! HP restored to full.")
                    else:
                        Print("Shrine dormant — player is already healthy.")

Line-by-line breakdown:

Lines What's happening
@editable ShrinePlate Exposes the trigger device so you can drag-and-drop it in UEFN's Details panel — mandatory for any placed device.
ShrinePlate.TriggeredEvent.Subscribe(OnPlayerEntered) Hooks the event. The handler fires every time any player steps on the plate.
OnPlayerEntered(MaybeAgent : ?agent) TriggeredEvent delivers ?agent (optional). The parameter type must match exactly.
if (A := MaybeAgent?) Unwraps the optional. If no agent was sent (e.g. a scripted trigger) the block is skipped safely.
player[A] Failable cast from agent to player. Uses bracket-subscript syntax — this is the correct Verse idiom.
P.GetFortCharacter[] Another failable call (brackets = can fail). Returns the fort_character that implements healthful.
FC.GetHealth() Reads current HP as a float.
CurrentHP < 50.0 Comparison is float-to-float — Verse does not auto-convert int literals here; 50.0 is required.
FC.SetHealth(FC.GetMaxHealth()) Passes the character's own max HP into SetHealth, guaranteeing a full restore regardless of any max-HP buffs.

Common patterns

Pattern 1 — Last-Stand Gate (SetHealth to exactly 1)

Before the final boss spawns, every player's HP is set to 1 — the ultimate last-stand moment on the clifftop arena.

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

# Wire BossSpawnButton to a button_device placed at the clifftop altar.
# When pressed, all players are set to 1 HP before the boss appears.

clifftop_last_stand := class(creative_device):

    @editable
    BossSpawnButton : button_device = button_device{}

    OnBegin<override>()<suspends> : void =
        BossSpawnButton.InteractedWithEvent.Subscribe(OnBossSpawn)

    OnBossSpawn(MaybeAgent : ?agent) : void =
        # Iterate every player in the game and cripple their HP.
        for (P : GetPlayspace().GetPlayers()):
            if (FC := P.GetFortCharacter[]):
                # SetHealth clamps to [1.0, MaxHealth] — passing 1.0 gives minimum survivable HP.
                FC.SetHealth(1.0)
                Print("Last stand! HP set to 1 for a player.")

Key point: SetHealth(0.0) is silently clamped to 1.0 — you cannot kill a player this way. Use damageable.Damage if elimination is the goal.


Pattern 2 — HP Threshold Check (GetHealth as a gate)

A lagoon vault door only opens if the triggering player has more than 75 HP — proving they survived the gauntlet without healing.

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

# Wire VaultPlate (trigger_device) and VaultDoor (mutator_zone_device or similar
# gate device) in the Details panel.

lagoon_vault_gate := class(creative_device):

    @editable
    VaultPlate : trigger_device = trigger_device{}

    @editable
    VaultDoor : conditional_button_device = conditional_button_device{}

    OnBegin<override>()<suspends> : void =
        VaultPlate.TriggeredEvent.Subscribe(OnVaultAttempt)

    OnVaultAttempt(MaybeAgent : ?agent) : void =
        if (A := MaybeAgent?):
            if (P := player[A]):
                if (FC := P.GetFortCharacter[]):
                    CurrentHP : float = FC.GetHealth()
                    MaxHP     : float = FC.GetMaxHealth()
                    # Require player to have > 75% of their max HP.
                    Threshold : float = MaxHP * 0.75
                    if (CurrentHP > Threshold):
                        VaultDoor.Activate(A)
                        Print("Vault opens — player passed the HP gate.")
                    else:
                        Print("Vault sealed — player HP too low: {CurrentHP}")

Key point: GetHealth() and GetMaxHealth() both return float. Arithmetic between them is straightforward — no casting needed.


Pattern 3 — Periodic HP Drain (Tick-style loop)

A cursed pirate ship slowly drains every player's HP by 5 every 3 seconds while they remain on board. Uses GetHealth to avoid draining below the safe floor.

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

# No extra devices needed — the drain loop starts automatically at round start.
# Add a mutator_zone_device (@editable CursedZone) to detect players on the ship
# and drain only those inside it.

cursed_ship_drain := class(creative_device):

    # Seconds between each drain tick.
    DrainInterval : float = 3.0
    # HP removed per tick.
    DrainAmount   : float = 5.0
    # Minimum HP the drain will leave a player at (cannot set to 0 anyway, but
    # we stop early to avoid the clamp silently doing nothing).
    HPFloor       : float = 2.0

    OnBegin<override>()<suspends> : void =
        loop:
            Sleep(DrainInterval)
            DrainAllPlayers()

    DrainAllPlayers() : void =
        for (P : GetPlayspace().GetPlayers()):
            if (FC := P.GetFortCharacter[]):
                CurrentHP : float = FC.GetHealth()
                # Only drain if above the floor so we don't fight the clamp.
                if (CurrentHP > HPFloor):
                    NewHP : float = CurrentHP - DrainAmount
                    # SetHealth clamps to 1.0 minimum automatically,
                    # but we guard above to be explicit.
                    FC.SetHealth(NewHP)
                    Print("Curse tick — HP now: {FC.GetHealth()}")

Key point: After calling SetHealth(NewHP), immediately calling FC.GetHealth() returns the clamped value — useful for logging or syncing a UI bar.

Gotchas

1. SetHealth cannot kill — it clamps to 1.0

SetHealth(0.0) does not eliminate the player; the engine silently clamps to 1.0. To eliminate a character use damageable.Damage(9999.0, ...) or a Damage Volume device.

2. You need fort_character, not just agent or player

GetHealth / SetHealth live on fort_character (via the healthful interface). You must chain player[Agent]P.GetFortCharacter[]. Both casts are failable — always unwrap inside if.

3. GetFortCharacter[] uses brackets, not parentheses

The [] suffix marks a failable expression in Verse. Writing GetFortCharacter() is a compile error. This is the single most common mistake when working with character health.

4. Float literals matter — no int↔float auto-conversion

Verse does not promote int to float. Write 50.0, not 50. Passing an integer literal where a float is expected is a type error.

5. <transacts> means rollback-safe, not "free"

Both calls carry <transacts>. You can call them freely from event handlers and loop bodies, but be aware that if the enclosing transaction rolls back (e.g. a sync block that fails), the HP change rolls back too.

6. Localized text for UI messages

If you want to display HP values in a HUD text device, message parameters require a localized value — you cannot pass a raw string or interpolated float directly. Declare a localizes helper:

HPText<localizes>(V : string) : message = "{V}"

Then pass HPText("{CurrentHP}") to the text device's SetText method.

Guides & scripts that use player

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

Build your own lesson with player

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 →