How to Set Progress Bar Fill Image That Changes With Fill Percent?
I'm trying to set my character's healthbar to consist of three images that correspond to his health level (a green image for 40+ health, an orange image for 20-40 health, and a red image for less than 20 health), but this is proving to be frustrating without the ability to simply set a binding to the fill image (why isn't this a thing?). I've gotten this system working with fill color, but I would prefer to be able to use images instead. I found this solution from which I created the following setup, but it's not working completely.
When I still have my fill color binding set up, my healthbar will retain the default green image and darken as I hit the lower health levels (I suppose being tinted by the color function). When I disconnect the fill color function, the fill image simply remains as the green image with no color change whatsoever. Please help?
asked May 18 '19 at 05:01 PM in Blueprint Scripting
Okay, after doing some thinking about what you've said I realized that the reason this wasn't working was because the function was only being called once and never updating. (There was also a bit of an oversight in that I had my Set Brush Resource nodes linking to my Break Progress Bar Style background image output instead of the fill image one.) I moved the function from the Event Construct to an Event Tick and it now works.
But I still have to ask, since you said it's better to not have this sort of thing being called constantly, is there a better way to have this check more than once? My first thought is to tie this to any events that change my character's health, but so far the only events I have that affect my character's health are two key presses that add/subtract 5 health for testing purposes and I'm not sure how best to tie the fill image to those functions. ATM I have my healthbar set to change the fill image according to my character's "Is Hurt" (20-39 HP) and "Is Very Hurt" (<20 HP) Booleans, which themselves are set to be checked whenever I press one of those keys. Any more input on this topic would be sincerely appreciated.
Thank you so much for taking the time to help!
answered May 18 '19 at 08:02 PM
Shouldn't the first comparison read 40 rather than 0.4? What range does the function return?
Because bindings fire every frame and you do not want to update it that often, especially here.
Follow this question
Once you sign in you will be able to subscribe for any updates here