Download

blueprint variable to widget

Hello,

I’ve got kind of a noob question here, I tried looking for it in the documentation but I got kind of lost.

I want to read a variable from a blueprint component and display it’s value on a widget menu. I’ve already set up the blueprint component with the required variables and a menu widget with some test text boxes. I also got the widget to be casted on screen.

All I need now is to read the variables from the blueprint component and display them on the widget.

Can anyone point me in the right direction?

Thanx in advance.

Check youtube. There are some other tutorials on the same subject.

Thank you for the link. Seems like I am on the right track.

I don’t want to use a variable in the player blueprint however. When I tried to do so, it worked. Now I need to pull the variable from the other blueprint.

I tried to use the same setup, but replace the “cast to MyCharacter” with “Cast to “blueprintname””. I don’t know how to use the Object slot though. (see attachment)

911036694db075bf515977be92544015a0d810c2.jpeg

Well that depends what it is and how many you have in a level.
If there is only one you can do a get all actors of class and get 0 and cast from that… gets a bit more complicated if you have more than one.
Another way is to use blueprint interfaces…

Personally i use Interfaces because they look cleaner even though i read somewhere there is a 0.01 - 0.05 slower performance using interfaces.

Getting 0 from all classes works perfect!

I have no idea how to work with the interfaces you mentioned, so i’ll just use the get all actors of class for now. I’ll check out the documentation on interfaces some time soon.

Thanks for the assistence!

I struggled with the same and solved it like this:

  1. create a.variable of the same type that you want to pass to your widget in the actual widget.

  2. In your Blueprint that contains the variable to be passed, add a) on ‘event play’, b) ‘create widget’ and pick the name of your widget, c) promote it to variable, d) get variable and drag of node and then type in the variable name of your widget’s variable r) set it and use the tobepassed variable as input.

In short, you create the widget again in your BP, make it a variable and through it you can access/set the widget’s variable.