How to get Widget Owner pawn in widget ?

Hi. I was wondering if there is any way to cast the character that contains widget ? In my AI blueprint I added a widget component to display the name of AI Character. Now I need to somehow cast to that character in my widget’s text binding to get AI name. I don’t really want create specific widgets for all my AI Classes.

1 Like

In your Blueprint Widget, make sure that the text component you are using to display the name is marked as IsVariable in the checkbox.

Now, make a new blueprint class deired from Widget Component. Set the Blueprint Widget you have created to be the “Widget Class” in default settings. Use GetUserWidgetObject and cast to the widget blueprint. From the cast node, get the text variable component and call set text. You can call GetOwner->GetDisplayName to get the display name to you want, and plug that into the set text.

Use this new widget component you have created in the AI characters, and you should be good to go.