Sending variable from BP to Widget


I have a blueprint in which I have a variable called ‘RowName’. I want to place many copies of this blueprint onto the map, and in each copy I want to set the ‘RowName’ to a different value.

For example, blueprint1’s RowName variable will be set to 1, blueprint2’s will be set to 4 and so forth…

When I player approaches a blueprint and presses ‘F’, a widget opens. The widget needs to retrieve the value of the RowName variable in that specific blueprint. The value will be used by the widget to retrieve a string from a row of which the name corresponds to the value in the variable from adata table and display it in a text box.

At the moment I tried casting but the text box displays the string set in the blueprint variable by default. When I change the value in blueprints on the map, nothing changes.

What am I doing wrong? Thanks

check that the widget is not retrieving the variable before it gets updated in the BP.

as a personal preference, i would use structs or maps instead of data tables… its just easier

1 Like

To update the widget with the new variable, you can do this one of two ways.
For clarification, I will call your blueprint ‘RowObject’.

Option 1: In your widget, include a reference to the RowObject. Set this reference to ‘expose on spawn’. Now, when you create the widget (you may need to refresh the node), you can pass in a reference to the specific RowObject the player has selected. Basically, this will be a way to store which instance the player pressed ‘F’ on.
Then, you can simply access the RowName variable in your widget by using your reference variable to the RowObject which has the RowName.

Option 2: You can also do the opposite (which is slightly easier)–instead of storing a reference to the RowObject in your widget, you can store a reference to the widget in your RowObject.
When the player interacts with ‘F’ and the widget is created, then save the widget reference in a variable (promote to variable).
Now, create a function in the widget called ‘Update’. It should have a name or string input for RowName. When it is called, you should update the widget so that the new RowName is the one inputted.
Now, any time you modify the RowName variable in your RowObject blueprint, call the ‘Update’ function on your widget reference. Input your RowName.

Basically, in the first option, the widget knows which blueprint the player selected. It then checks that reference any time it wants the RowName.
In the second option, it is the reverse; the blueprint itself knows which widget was created, so when the blueprint updates, the widget does too. NOTE: You will want to make sure you are calling the widget’s update function right after you create it, too.

In both scenarios, you should be creating the widget inside of your RowObject blueprint. That way, you can either save the widget reference inside of the RowObject, or give the widget a reference to the RowObject itself.

Sorry if this is unclear, I can explain more if you want. I don’t know how much you already know about functions and references.

1 Like

Thanks a lot guys, I managed to get it to work! :wink:

For anyone in the future, this is what I did.

In the object blueprint (the object laying in the world) I have a name variable called RowName

I create a widget when the player overlaps with a trigger around the object and presses F.

The widget contains a variable called Documents which is referenced to self in the blueprint.


In the widget, I made a bind for the text box. In the bind, I have a cast to the object blueprint. From the cast, I retrieve the RowName variable and I use it to retrieve a row from a data table. I break that row into structures and convert them to string which is then displayed by the text box.