Page Info
Engine Version:

6. Communicating with the HUD

Choose your OS:

In this step, we will update the values displayed on our HUD Widget Blueprint by communicating with our Character Blueprint to get values stored in it for Pulls, Shots, and Score. To do this, we will use a Cast node to access the player's Character Blueprint then Bind properties in our HUD to values in our Character Blueprint so they automatically get updated when those values are updated in the Character Blueprint.

Our game is almost complete, let's finish it off by updating the HUD.

  1. Open the HUD Widget Blueprint you created.

  2. Click the Graph tab inside your HUD Widget Blueprint.


  3. Right-click in the graph and add the Event Construct node.


    This node is similar to an Event Begin Play and is called when the Widget Blueprint is constructed.

  4. Add a Get Player Character node and CastTo FirstPersonCharacter.


  5. Off the As First Person Character pin, select Promote to variable and rename the new node to MyCharacter.


    You can rename the variable from the My Blueprint window by selecting the variable and pressing F2.

  6. On the Designer tab, click the value for Pulls then next to Text in the Details panel, click the Bind option and choose Create Binding.


    This will open a new graph for the binding.

  7. Hold Control and drag in the MyCharacter variable, then off it Get Pulls and connect it to the Return Value of the Return Node.


    The To Text (Int) conversion node will automatically be created. We are now set to properly display our Pulls value.

  8. On the Designer tab, click the value for Shots and in the Details panel, click the Bind option and create the binding below.


    This will update and display the proper amount of shots left per pull.

  9. On the Designer tab, click the value for Score and in the Details panel, click the Bind option and create the binding below.


    And finally, this will get and display the proper score for the player when hitting a rock.

  10. Click Compile and Save, then close the Blueprint.

  11. From the Main Editor view, click the Play button to play in the editor.

That's it; your simple shooting gallery game is complete. To spawn a rock, press F as we bound it do that event in a previous section. Over the course of this guide, we have learned how to communicate between three different types of Blueprints using an Event Dispatcher, Cast nodes, and Binding. We have learned how to pass information from the level to a Character Blueprint as well as how to communicate variables from the character to a HUD.

In the final step, you will see some examples you can take to alter this project and make it your own. You will also be provided with links to additional documentation that covers topics in this guide.