How can I recieve a variable from my level blueprint to add to hud?
I am attempting to receive integers from my level blueprint to bind to text objects within my widget blueprint for hud. Below I have attached pictures of my scoring system created in my level blueprint and of my text that I am currently trying to bind. Any help would be appreciated. Thanks.
asked Mar 09 '16 at 04:32 PM in Blueprint Scripting
The way I would do it is make two score variables in the hud blueprint. Bind the text on the hud to the variables. Then all you would have to do is create a reference to the hud in the level blueprint and change the text to whatever the new score is. When you create the HUD in-game set it to a variable that you can then call from that blueprint to edit the variables. For example, if you create your hud in the level blueprint you can create a variable of the hud widget type (whatever you named it) and set the created hud to that. This is what you can call to edit the variables in the hud class. So basically on your On overlap you would get the HUD and set the variables accordingly.
Here is an example level blueprint creating the hud widget
Here is an example Hud class assigning the variables to change the text. Note that this is only one, the other one is the same, just uses the other variable. When you place your text on the canvas under the text hit bind and it will bring up these functions for each text element.
This setup ups the first score by 1 every time you overlap the trigger volume, you can change the actual function however you'd like though.
NOTE: If you're creating the HUD in another blueprint that's not the level blueprint you'll have to first get that blueprint to use the created hud. For example, if you created the hud in the player character class (FirstPersonCharacter, THirdPersonCharacter etc) you would need to get player character and then grab your hud object to edit the text.
answered Mar 10 '16 at 09:10 AM
You can use an Interface in your widget and call the interface function from your level blueprint.
Add the interface in you widget, there you can take the event and can add set the float. In the Level Blueprint you just need a referance to the widget, easiest way would be to add it in the level blueprint to the viewport and promote it to a variable. Then take it and there you should see the interface funtion, that you can call.
answered Mar 10 '16 at 01:57 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here