Trying to get a "live" number out of a HUD function.

I’ve been trying to get this value, that changes ‘live’ as you use ammo in the game to be able to be stored somewhere and change in real time - but take this value and use it in the Player Blueprint so I can use it to determine conditions on the go.

But no matter what I try, when I get that value printed outside the HUD, it is never live - for example, the Total Ammo is a fixed variable that only changes in HUD when you start using Ammo, but elsewhere it always reads as a fixed variable of the total ammo that can be carried by that gun. So I am just unable to get this variable to be read live anywhere outside the HUD.

Help!

SOLVED! I was already casting to AWM in that function, so I made a new variable in the AWM bp called RealTotalAmmo, which is being set by that same cast to AWM function in the HUD bp. So now, when I equip the AWM, the RealTotalAmmo is live at runtime, and I can use that number to interact with other runtime elements in the level.

Expensive? Probably yeah. But it works! XD

1 Like

Your inventory system should be making calls to UI when it updates itself.

Ammo deduction → Set ammo value → Call UI Manager

UI Manager → Calls function to Set Ammo Text.


Overall your UI should be 100% managed by the controller class. When you create a widget you store a base reference for it.

When you do something in your character, weapon class etc you’d use BP Interfaces to call up to the controller to have it update the UI via the stored widget reference.

1 Like