Set the text block of a Text Block declared as a variable in an User Widget

Hi!

How can I set the text of a TextBlock declared as a variable in an User Widget?

This User Widget is a component in a blueprint a character:

The PlayerName is the User Widget.

How can I set the text to this Text Block?

Thanks!

Get Component → Get User Widget → Cast → Get Text Block → Set Text

Thanks, but it doesn’t work.

I don’t think an User Widget is a component. I have tried this, but I can’t find the class for the User Widget or the WBP_PlayerName:

You say Player Name is the User Widget but that’s not possible. What is Player Name?

  • a child actor component?
  • a widget component?
  • an actor component?

Icons in UE5 are changed and I can’t tell what is what. :upside_down_face:


Assuming it’s a widget component:

My original answer would be correct:

Get Component → Get User Widget → Cast → Get Text Block → Set Text

3 Likes

This is the PlayerName component in the Character:

Parent class: User Widget

You can see the variable: TextBlock_PlayerName.

And in the character:

On its properties you can see that it is an instance of the User Widget class:

So, Or I’m a Wizard and I make magic or I haven’t understood what you are trying to tell me.

No, it’s not. This is a 2D UMG widget the Widget Component holds onto. The WC will instantiate a 2D UMG widget for you. That 2D UMG widget has the text block you seek. You need the peel it from the widget component it’s embedded in.

My answer is correct. Just follow the screenshot please. This (but cast to your widget, ofc):

In the above screenshot Widget Component would be the Player Name widget component.

2 Likes

Well, I’ve just started to learn and I don’t know too much about Unreal.

Oh, you know enough. I know your name, I’ve seen you around! :smiley:

Start here:

You’re almost there.


This is a thing a lot of folks stumble on:

Not even sure how many times I’ve answered this very question - hence my confidence.

1 Like

Thanks! But this is the first time I try to do something like this.

Thanks a lot!

2 Likes

Tell it to the recruiters, they don’t believe me.

2 Likes