
Make Your Own Event: Announce Victory With a HUD Widget
What you'll learn
So far you've been a listener — subscribing to events that devices broadcast. Now you become the announcer. You'll learn how to:
- Declare your own
event(agent)that carries a player as its payload. Signalit from your game logic when something meaningful happens.Awaitit in a watcher loop — the custom-event twin of theSubscribeyou use on devices.- Have the handler show a real HUD widget on the winner's screen with
GetPlayerUI[]andAddWidget.
How it works
Devices announce device things. But your game has moments no single device owns: a puzzle solved, a wave cleared, a boss defeated. Those are yours to announce.
Verse gives you a ready-made announcer type: event. You write the kind of data it carries inside parentheses. An event that carries a player (agent) looks like this:
BossDefeatedEvent : event(agent) = event(agent){}
Read it as: "BossDefeatedEvent is an event that carries an agent, starting as a fresh event."
There are two verbs:
Signal(Payload)— the moment of "it happened!" Every task waiting on the event wakes up, each receiving the payload.Await()— inside a<suspends>context, pause (for free) until the nextSignal, and receive the payload. Wrap it in aloopand you have a handler that runs on every Signal — your own version of theSubscribeyou call onbutton.InteractedWithEvent. (Only device events arelistenable, which is what carriesSubscribe; your ownevent(t)pairsSignalwithAwait.)
To make the payoff visible, our handler reaches the winner's screen through the player-UI API. GetPlayerUI[Player] is fallible (note the []), so we bind it inside an if. Then we build a text_block, drop it in a canvas, and call PlayerUI.AddWidget(...).
Let's build it
A real button drives our own event. Pressing it calls DefeatBoss, which Signals BossDefeatedEvent, which wakes the Await loop that runs OnBossDefeated — so device event → your event → your handler → a widget on screen.
Try it yourself
- Place a Button Device in your level and assign it to the
BossButtonfield in the Details panel. - Push this Verse device, launch a session, and press the button.
- Watch the log (
The boss is down!thenVictory!) and the HUD — the victory text appears on the presser's screen. - Extend it:
spawna secondAwaitloop onBossDefeatedEvent(e.g. one that grants a reward, one that shows the widget) and watch both wake from a singleSignal. - Cleanup practice: store the device subscription (
ButtonSub := BossButton.InteractedWithEvent.Subscribe(...)) and callButtonSub.Cancel()after the first press so the boss can only be defeated once.
Recap
event(agent)declares your own announcer that carries a player payload.Signal(Winner)wakes every task paused inAwait(); aloop:aroundAwaitis your handler — it runs once per Signal.- Only device events (
listenable) have.Subscribe; your ownevent(t)pairsSignalwithAwait. text_block.DefaultTexttakes amessage— make one with a<localizes>function, never a raw string.GetPlayerUI[...]is fallible — bind it in anif, thenAddWidgetacanvasto actually put your announcement on screen.
Get the complete code — free
You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.
Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.
Verse source files
- 01-device.verse · device
- 02-fragment.verse · fragment
- 03-fragment.verse · fragment
- 04-device.verse · device
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 Events in Verse — creating event(t), Signal, Subscribe 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.
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.