Float data from Level BP to Widget BP
Hey guys, I've been struggling with this for a few days now. I've set up a simple timeline system to handle the day/night cycle of the game world. It has two tracks, one controlling the rotation of the sun, one for the time (0-24.)
I've tried copying and altering various examples to other people's similar problems however none of them are working.
I'm trying to create a few widgets that will use the float value. One to display the time, one to display the time remaining until sunset/sunrise. I also need the value so I can script some warning pop ups for the HUD.
Does anyone know the easiest way to do this?
Here's a picture of the blueprint.
I think I have a good solution for you. It is a little long, but it will get the job done.
First I will go over my level Blueprint setup.
I used my level Blueprint to create and store my widget as you can see in the picture below.
Next I created a simple variable called "TestVar" and set its value in the Tick method of my Level Blueprint. This variable was only created for testing my methods. In your case you might want to use your values for displaying the time.
In the Tick method of my LevelBlueprint, I am assigning a value to my TestVar and am calling a function on my widget called "UpdateTestVar." We will create this method in our widget later. Below is a picture of my setup.
Secondly we will go into my widget setup.
First I create my widget using the editor and named my widget "TestWidget". My "TestWidget" has two import functions which allow it update and display the value of the variable from my Level Blueprint. It also has a variable called "WidgetVar" that stores the value of the variable getting displayed.
The picture below is of the first function called "UpdateTestVar." All it does is to set the value of the "WidgetVar" variable to a specific input. A picture of this is shown below.
The second function is used to update the text field of my widget. You have to create this function in a unique way. First go to the Designer tab of your widget and select the text field you are working with. Then look in the Details panel for a category called "Content". Next you should see a field called "Text" with a drop down box next to it. Choose the "Create Binding" option in this drop down to create your function as seen in the picture below.
Now go to this newly created method and use it to insert the value of your widget variable into your text field as seen below.
So now you should have a widget that is receiving a value from your Level Blueprint and is drawing that value onto the screen.
I know this tutorial was a little long so feel free to ask any questions in the comments below.
I hope this answer helps,
answered Jul 23 '15 at 10:54 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here