So I am making a First person shooter. In this fps I have made some basic enemies that have a health bar on top. The actual function (health decrease and death) are working fine. And the health bar was working correctly too. I set up the enemies so that they die in 2 hits (a total of 1 health, with 0.5 damage in each shot) and the health bar widget worked fine. What i cant get to work however is to reflect the health loss in a progress bar correctly when i increase the hits that are required to defeat the enemy. I am not increasing the total health, i am simply decreasing the damage per shot (from 0.5 to 0.25) In the first video i show the health bar widget working correctly when i am dealing 0.5 damage in each shot, killing the enemy in 2 hits. In the second video i show the health bar widget working incorrectly when i deal 0.25 damage in each shot (you can also see the health remaining after each shot on the top left corner)
In this screenshot is the variables that i use to change the damage per shot and the total enemy health.
ok well first things first you dont need that cast node that you have in the widget (in the current implementation). also the way you are getting the health is a poor way to accomplish it since you are getting all actors of a class( this could cause issues).
why are you not using the built in damage systems? there are nodes for apply damage and event any damage. if you were to use those you could create a much more dynamic scenario.
to start try cleaning up the widget and see if that helps. if not we can work from there. or you could just set the value of the health bar manually as pictured below. make a variable on the health bar and bind that to the progress bar percentage. then whenever damage is applied just update the variable.
I didnt even know that these nodes existed, thanks for telling me!
I looked up some tutorials and most seem to use line trace to work with these nodes, however i use a projectile. So i assume that what i would have to do is to apply damage on event hit of the projectile and cast to the actors that i want for the apply damage node.so my problem now is what do i plug in, in the object thingy when casting(i feel like the answer is going to be simple but i cant seem to find it on my own)
When using the apply damage node you dont beed the cast node. If you look on you hit event node there should be a blue pin that says other actor. Just drag off that pin and plug it into the damaged actor. This way anything you shoot than can take damage will. I would post a picture but im on my phone right now
That makes sense. Ok so i got it to work with the apply damage and any damage but i am still not sure how to fix the health bar issue i mentioned above. (i didnt change anything in the widget yet, not sure what to change)