I have a hotbar that holds items and their respective data, in particular their durability, displayed as a progress bar inside of the widget slot. The durability is changed whenever the item is used, or the item takes damage (weapon/armor). My hotbar is set up to refresh the slots and their data whenever the inventory is drawn, but only then is the durability ever updated. The hotbar is basically a panel that modularly? fills with slots respective to the amount/data in the hotbar components array.
I’ve came across a few solutions to update the children of the hotbar and I’m just wondering if I’m approaching this right. I can directly call the update progress bar function from the hotbar to the slot, but only the last widget of the panel is targeted.
The first solution was to refresh the slots as it does whenever the inventory is drawn, but that would mean looping through the hotbar array (refer to WB_Hotbar “on updated slots”) every single time a weapon is swung or the character takes damage.
The second solution was to make a separate array within the hotbar of the individual slot widgets and target specific widgets at their index, since I couldn’t find a way to “get child at index” and directly call a function from a base widget class.
The third solution which seems to work the best is to simply create an interface and call the function down the line until I reach the hotbar and then calling the interface implemented in the slot, targeting the base widget class by using “get child at index” and using the return as the interfaces target.
So what would be the right way to approach this? Is there a better way to achieve this result? For reference, the “set durability” is an interface implemented into my characters BP, called by respective weapons/armor. The WB_HUD is created inside of my characters BP, and within the HUD the hotbar is created, and the hotbar fills the panel with slots, so I’ve just linked custom events down the line. Is there a better way to go about this?