How to set widget component text on clients?

Hi there. I’m trying to have it so my character class has a widget component that acts as a nameplate so other players in a multiplayer session can see their name above their head. I have no idea how to set the widget text on clients though. Can anyone give me an idea of how to do this? Thanks in advance.

Hey @blastertoad, Could you help me out?

Hello again Brylos. I have an idea how to do this and will blueprint it tonight.

Set your player name in the player state. Then when your pawn is spawned cast to player state and get player name var.

Hi blaster thanks for the reply. Could you elaborate a bit more? I can’t seem to set the player state name. Does it have to be from the player state or can it just be any replicated variable? Also when it comes to the widget component that is a part of the character, do you mean I should just create a bind on the widget text to the variable on the character via [Getplayercharacter,cast to character class, get variable, plugin to return node] or some other way?

Player state is replicated to all clients so it is a safe spot to store names and the like. In game mode when player joins set name variable via custom command run on server. Then spawn your actor and possess. In the actor on begin play get player state, cast to your state, get you vat player name, and then get widget component, get your widget, cast to widget, set text. I will have more time tonight then yesterday so if you are still having issues I can work something out.

Thanks for the further explanation :slight_smile: it works great. I gotta write you a check once I become profitable lol.