Connecting UI values to player variables
To allow our UI elements to pull data from our player variables, we need to revisit the HUD Widget Blueprint. To get our UI to update with player data, we will create a binding. Bindings give us the ability to tie variables or functions of a Blueprint to a Widget. Whenever the variable or function is updated, that change is reflected in the Widget automatically.
So, instead of manually updating both the player's health stats and our Widget every time the player takes damage (so that the health meter display changes), we can bind the meter to the PlayerHealth
player variable. Then, only one value will need to be updated.
Creating bindings for health and stamina
To create the bindings of the PlayerHealth
and PlayerStamina
variables with the progress bars' UI, follow these steps:
- In the Content Browser, access the
/Content/FirstPersonBP/UI
folder and double-click on the HUD Widget Blueprint. - In the HUD UMG Editor...