I’m currently trying to get a widget that shows the stats of a character to show up in a ‘Common Activatable Widget’. The widget is getting added on pre construct.
Then it’s being called when a buttons pressed on the main menu. This is all working fine however the stats don’t update when it’s being added like this.
If I create the widget and add it to viewport inside the pawn with the stats it works as intended. This is how I’m getting the stats to connect to the different UI elements.
I managed to work out a way to get this working by using event dispatchers to track the stats changing. I then bound to the events inside the widget to update the different bars.
This is all working fine with 1 character but once I spawn in more than 1 the bars start jumping around. I’m pretty sure this is because the event dispatchers are sending the stat changes for both characters at the same time to both widgets.
This is how I have it set up
Character has a function that drains his thirst meter. This also has the event dispatcher in it.
Then on the pre construct of the widget I get all actors of class with a loop then bind to the event form the character.
Then in the widget that tracks the stats it get’s a reference to the character and the stats. Using this function the stats are turned into percentages of the different bars.