What you'll learn
- How to drive a real
hud_message_devicefrom Verse withSetText,Show,SetDisplayTime,Hide, andClearAllMessages. - How to author a localized
message(with interpolated parameters) instead of passing a raw string. - How to subscribe to the device's
ShowMessageEventto react when a banner appears. - How to pin a personal standings banner to each player using the player-UI stack:
GetPlayerUI[],AddWidget, acanvasand atext_block.
How it works
The hud_message_device is your beach-wide announcer. Its two most useful calls are:
SetText(Text:message)stores the message, thenShow()(orShow(Agent)) displays it.Show(Message:message, ?DisplayTime:float)does both at once.DisplayTime := 0.0shows the banner forever until youHide(); a positive value auto-hides.
Every text parameter is a message, not a string — so we declare a <localizes> function like LeaderMessage(Name:string, Coins:int):message. Interpolation ({Name}, {Coins}) fills in live data.
That covers the shared shout. For a personal banner that each hunter carries, we drop to the player-UI layer: GetPlayerUI[Player] (fallible — bind it in an if), then AddWidget(...) a canvas whose slot holds a text_block. This is the piece the requirement demands — it actually paints a widget onto one player's HUD, independent of the device's queue.
Let's build it
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# Localized message — interpolates live leaderboard data into a `message`.
LeaderMessage<localizes>(Name:string, Coins:int):message = "Captain {Name} takes the lead — {Coins} coins!"
cove_leaderboard := class<concrete>(creative_device):
# The shared beach megaphone. Configure Display Time in User Options too.
@editable
Announcer:hud_message_device = hud_message_device{}
# Stepping on this pad marks a new leader for the demo.
@editable
LeadPad:trigger_device = trigger_device{}
OnBegin<override>()<suspends>: void =
# React when the device actually shows a banner on someone's screen.
Announcer.ShowMessageEvent.Subscribe(OnBannerShown)
# New-leader pad drives both the shared shout and a personal widget.
LeadPad.TriggeredEvent.Subscribe(OnNewLeader)
# Called by the device once a message is on-screen.
OnBannerShown(Agent:agent):void =
Print("HUD banner shown on the cove.")
OnNewLeader(MaybeAgent:?agent):void =
if (Agent := MaybeAgent?):
# Demo standings — in a real game read these from your score store.
Name := "Bella"
Coins := 300
# Persistent shared shout (0.0 = stays until Hide/ClearAllMessages).
Announcer.SetDisplayTime(0.0)
Announcer.SetText(LeaderMessage(Name, Coins))
Announcer.Show()
# Pin a personal banner directly onto THIS player's HUD.
PinPersonalBanner(Agent, Name, Coins)
# Uses the real player-UI stack: GetPlayerUI[] + AddWidget + canvas/text_block.
PinPersonalBanner(Agent:agent, Name:string, Coins:int):void =
if:
Player := player[Agent]
PlayerUI := GetPlayerUI[Player]
then:
Banner := text_block{DefaultText := LeaderMessage(Name, Coins)}
Root := canvas{Slots := array{
canvas_slot{
Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.1}, Maximum := vector2{X := 0.5, Y := 0.1}},
Alignment := vector2{X := 0.5, Y := 0.0},
SizeToContent := true,
Widget := Banner
}
}}
PlayerUI.AddWidget(Root)
Try it yourself
- Change
DisplayTimefrom0.0to3.0inSetDisplayTimeand watch the shared banner auto-hide. - Call
Announcer.ClearAllMessages()from a second trigger to wipe every queued banner at once. - Swap
Announcer.Show()forAnnouncer.Show(Agent)so only the triggering hunter sees the shout. - Read real coin totals from your own map/score store instead of the hard-coded
300.
Recap
SetText+Show(or the combinedShow(Message, ?DisplayTime)) drive thehud_message_device;0.0display time is persistent.- Text params are
messagevalues — build them with a<localizes>interpolated function, never a raw string. - Subscribe to
ShowMessageEvent/ClearAllMessagesEventto react to banner lifecycle. - For per-player HUD pixels, use
GetPlayerUI[Player](fallible) thenAddWidgetacanvasholding atext_block.