Driving Live HUD Widgets from Device Events in Verse
What you'll learn
- How to access the live
player_uifor each player and attach a widget to it. - Building a
text_blockand hosting it inside acanvasfor positioning. - Subscribing to a
trigger_deviceevent so gameplay drives your interface. - Pushing updated values into a widget with
SetTextso the HUD stays in sync.
How it works
Each player has a player_ui you fetch with GetPlayerUI[Player]. You add widgets to it once with AddWidget, then keep a reference to the widget so you can mutate its properties later. A canvas lets you position widgets in its slots; individual widgets like text_block expose setters such as SetText.
The reactive part comes from Trigger.TriggeredEvent, a listenable(?agent). Subscribing returns a cancelable handle. Inside the callback we bump a counter and immediately call SetText on the stored widget — no per-frame polling, the update happens exactly when the event fires. Note that GetPlayerUI[...] uses square brackets because it is fallible, so it must be called inside an if.
Let's build it
Place a Trigger Device in your level, drop the ui_state_driver device into the scene, assign the trigger to the editable slot, and playtest. Every time the trigger fires, an on-screen counter updates live for every player.
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/UI }
using { /Verse.org/Simulation }
# Drives a live HUD text widget from a trigger device event.
ui_state_driver := class<concrete>(creative_device):
@editable
Trigger : trigger_device = trigger_device{}
# The widget whose text we mutate each time the trigger fires.
Readout : text_block = text_block{}
# Running count pushed to the HUD.
var CurrentValue : int = 0
OnBegin<override>()<suspends>: void =
# Attach the readout widget to every player's UI once at startup.
for (Player : GetPlayspace().GetPlayers()):
if (PlayerUI := GetPlayerUI[Player]):
# A canvas positions widgets in its slots; add our text into it.
MyCanvas := canvas:
Slots := array:
canvas_slot:
Widget := Readout
PlayerUI.AddWidget(MyCanvas)
# Show an initial value before any events arrive.
Readout.SetText(StringToMessage("Progress: 0%"))
# Subscribe so every trigger activation pushes a fresh value to the HUD.
Trigger.TriggeredEvent.Subscribe(OnTriggered)
# Runs whenever an agent (or code) fires the trigger.
OnTriggered(MaybeAgent : ?agent): void =
set CurrentValue += 1
Percent := CurrentValue * 10
# Push the new state straight into the widget the Scene Graph shows.
Readout.SetText(StringToMessage("Progress: {Percent}%"))
Print("UI state driven: progress is now {Percent}%")
# Helper: wrap a string as the `message` type SetText expects.
StringToMessage<localizes>(Value : string): message = "{Value}"
Try it yourself
- Change
CurrentValue * 10to a different multiplier and watch the readout climb faster or slower. - Add a second
text_blockfield and update both fromOnTriggeredto show a label plus a value. - Call
Readout.SetVisibility(...)to hide the widget until the first trigger fires, then reveal it.
Recap
You wired a trigger_device event to a live HUD widget: fetch each player's player_ui with GetPlayerUI[Player], host a text_block inside a canvas, add it with AddWidget, then subscribe to TriggeredEvent and call SetText in the handler. This event-driven loop keeps the interface synchronized with game state without any polling.
Check your understanding
Test yourself with an interactive quiz and track your progress + earn XP — free for members.
Turn this into a guided course
Add Driving Dynamic UI State via Scene Graph Variables in Verse 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.
References
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.