I know there are many posts on the same topic, but I’ve read some and haven’t seen a solution to my problem.
Basically i made a blueprint interface and a Blueprint component to make a damage system (take damage, heal, etc). This system does work because i can print the value of the damage and the remaining health of the character, but the widget isnt updating.
This is the code of the Get Percent function calling the max health divided by current health value :
Judging by the script, I’m not sure how you imagined this to work. Any reason you can’t simply receive and process the damage in the actor → update widget. You know, the standard, simplest and most efficient event based approach.
you create a widget, but never reference it
have any damage in the actor call the event in the widget using its reference
I was following Ali’s tutorial (https://youtu.be/o3uFXnNxwKE?si=tgrh6dPSLCNyS4fe&t=2900) and thats what he shows. He creates the widget, the reference to the interface and use the values storaged to complete the get percent. Last thing is to add the widget to any character, creatw widget, set widget
Because it’s a widget component we pipe an interfaced actor into.
Not sure about this one, tbh. The YT comments praise the creator for the approach to modularity and efficiency yet we can see a bound function in use - bound functions execute every frame. So this GetPercent functionality polls 120 times per second. It’s OKish if it’s for just the player, but if the plan is to have a bunch enemies do that, I’d avoid it for this reason alone. This is one of the 1st thing Epic recommends not doing But you do you, ofc. Why update something non-stop when we can do it once - when needed.
But then again, I did not watch the whole thing, perhaps they address it - or even have a reason to handle it like so - perhaps the progress bar will be animated.
Hard to tell why it does not work for you without seeing how the rest looks like. Is the interface implemented? How is it actually handled? Check those values:
That’s the whole thing and does not require creating an additional interface. Note that UE already comes with a full interface damage system with replication, a system that also includes entire class damage system - it really works great for damage processing in complex systems.
I’ve seen too many wheels reinvented recently, consider it a rant.
The interface its implemented and handles the health, the damage and other functions like healing, blocking (being hit without losing life) etc
The values of the Get Percent are 2 variables from the Blueprint Component added to every actor that will take damage. The health one will be changed with the Take Damage function 123 posted by anonymous | blueprintUE | PasteBin For Unreal Engine (but anyways, this part works, when the enemy has less than 25% of life, he hides, and when life = 0, he dies)
Considering that I only want this part in particular, the life bar, to control the different types of damage I will do and not for the final product, if I see that it gets complicated, in the end I will make a simpler code for the widget, like the one you sent, even if I have to repeat it for each type of enemy.
I have reviewed all the code and if the widget was not the problem, it was the functions “get current health” and “get max health” implemented by the interface, and in both the variable Max health was in use instead of current health (just a missclick)
So basically the widget was getting the percent of “100/100” all the time.Yikes.