VerseBuilderDocs

Docs/Recipes/HUD with health bar

Recipe: HUD with live stat bar

Show a live counter (lives, armor, kills) on the HUD that updates instantly when the underlying variable changes.

Last updated 2026-06-06

Ingredients

  • Variable lives — int, scope player, persist off, default 3.
  • UEFN devices: 1 Elimination Manager (or equivalent), 1 HUD Message device anchored to the corner of the screen.
  • HUD widget: a label showing "Lives: {lives}" with the variable token.

Build it

  1. Add the variable

    lives (int, player, persist off, default 3). Off because lives reset every round.
  2. Decrement on death

    WHEN On Eliminated → DO Decrement Variable lives by 1, Show Variable HUD lives. The Show Variable HUD action pushes the latest value to the HUD widget for the affected agent.
  3. End when lives hit zero

    Second rule: WHEN On Eliminated IF Compare variable lives ≤ 0 → DO End Game. Same trigger, gated by threshold.
  4. Initial HUD push

    WHEN On Player Joined → DO Show Variable HUD lives so the widget shows the starting 3 lives the moment the player arrives.

💡 Tip

Show Variable HUD is the pattern for any live counter — coins, kills, armor, wave number. Call it after every change.

📌 Note

The action takes only one param — the variable to display. The on-screen text (e.g. "Lives: {value}") and position are configured on the HUD widget itself, in the HUD tab. One source of truth, set once.

Generated Verse

EliminationManager.EliminatedEvent.Subscribe(OnDeath)

OnDeath(Result:elimination_result):void=
    if (Agent := Result.GetEliminatedAgent[]):
        SetLives(Agent, GetLives[Agent] - 1)
        HUDMessage.Show(Agent, FormatLives(GetLives[Agent]))
        if (GetLives[Agent] <= 0):
            spawn{ EndGameAfterDelay() }

Variations

  • Low-health popup — extra rule: IF Compare variable lives = 1 → DO Show HUD Message "Last life!".
  • Regen on kill — combine with the Score tracker: every X kills, award +1 life via Increment Variable lives by 1.
  • Team lives — switch scope to global and you have a shared lives pool.

Gotchas

⚠️ Watch out

Don't forget the initial push. Without a Player Joined rule, the HUD shows nothing until the first death — confusing for new players.

📌 Note

show_variable_hud resolves the variable for the current agent and formats it through a generated message. You don't format it yourself.

See also