I want to display HUD messages, like “King J Arthur is in the lead!” but I can’t figure out how to get a player’s name when I have the player object. I would think there would be a function to do so.
In Verse you currently can’t access the names of players. I’m not sure if it will ever be possible, as it could be used to harass specific players
With a HUD message device you can use {instigatorname}
, but I’m not sure if you can control which player triggers the devices from code
Maybe there’s a way with some other devices channels or direct event binding, but I haven’t looked too deeply at how that works
Well, I’ll play around with the {instigatorname} tag and see if I can get something to work.
I’ve seen HUD messages displayed in Red vs. Blue where it says “King J Arthur is on a killstreak!” – so I figured something like that must be possible.
Tried to look into it, and found out you can link a Trigger Device with a HUD Message Device and call the Trigger function through Verse
The Trigger Device needs to setup
You have to Add the OnTriggered Event from the Trigger Device to the “User Options - Functions” on the HUD Message Device
Then from Verse you need a reference to the trigger device, and call .Trigger(Player) on it
If you change the message in Verse, you can’t use {instigatorname} as Verse doesn’t have access to that variable, so if you wanted to write a message like “{instigatorname} has {X} kills” then you would have to make two HUD Message Devices and set one up in the editor to say something like “{instigatorname} is in the lead”, and change one in Verse to read “with {X} points!”
Just a heads up if you’re going to be changing the message in verse, the function takes a message, not a string, so here’s how you can make a string into a message:
ToMessage<localizes>(I:int):message="{I}"
Thank you for the thorough investigation on this! It makes sense, though a lot of workarounds are required. I guess that is kind of the name of the game for now.
I appreciate the clever way to convert the string into a message – I had been creating a separate function for every message string I needed.