Compare clicked object name inside Widget

Hi all,

I really can’t get my head around this where and how to keep information. Basically, I want to have a widget which would give me random words from a list (like a lamp, chair, and so on) and I as a player should press on mesh object (converted to blueprint) making sure it’s the right object. Over a day I am trying to get my head around that (most likely not the wisest :confused: ) and understand how to compare two different assets (Widget and actor). Should I use a simple “text render” component inside asset and cast to UMG actor? As well I have no idea how to change the random text inside UMG (different topic but better ask straight away)… Any advice to the right direction would be much appreciated :slight_smile:

Have the widget generate and display the word - store the result in a text variable *or *you can read it from the text box directly. For the objects, either give them tags or have them store their own text variables. When the user clicks the object (via get hit under cursor for objects, for example), read the tag or stored variable of the clicked object and compare (equal text node) it with the text from the widget.

To make it better and not prone to typos, look into enumerators - then each object / widget can have an enum value you choose from a dropdown list rather than manually typing text into each new object - this allows you to scale things up later on.

To randomly generate words, add text to a text array - use *random *node to fetch an element.

Do tell if you need more details regarding anything above!

Ye, I might need a little more help :confused: “read the tag or stored variable of the clicked object and compare (equal text node) it with the text from the widget.” In which blueprint I need to read it (widget or object)? Both of them are showing errors when trying to access a different blueprint… Can’t get proper references to any. Daaamn programming is FUN :confused:

Technically you can do it anywhere, here it is in the Player Character. Create the widget (and store its reference) and do the trace there to retrieve the reference of the world object.

In order to keep it as simple as it gets, I created text variables in both the widget and the object and called it *FurnitureType *and the rest happens in the player character:

This can be, obviously, vastly improved but should work as is for something straightforward.

Thank you for helping to develop myself ! :slight_smile: