Healthbar Not Updating Based on damage (pvp)

I am working on a project for school, a local multiplayer arena shooter and the damage between the players will not work, I have set up debugging strings and they are all returning how they should but the damage is not being shown on the health bar, the bar I am using is a “progress bar” if that makes any difference. Thanks in advance. :slight_smile:

Here is a youtube link to show the problem in action:
[- YouTube]

Is that first image a binding in the widget to the progress bar? You never “set percent” of the progress bar. Also if that is NOT a binding, you never call that function.

Here, this is a tutorial I made that actually deals with a health bar. Start from 2:45 that is where I script the “set percent”. Mine is located in a function not a binding but, the code is the same. Just follow along and you should be good from there.

It is a binding in the “percent” tab, ![alt text][1]

also im not too sure what you mean by “set percent” I have searched for that term within the binding blueprint and nothing, sorry I am very new to this. thanks for your patience.

I’m not sure how I could possibly modify this so that when a ray trace hits a player the health reduction code will fire, If I just had a button to take health off I could but I have been at this a few hours now and nothing.

Im hoping all im missing here is the correct target, which for the life of me I cannot work out.

Ok, I see the issue. I don’t think you have anything bound to “apply damage”. That event just makes it easier to script damage events but it doesn’t do it for you. You still need to script the “on take any damage” event.

If you wanted to just straight out subtract health and set it again like you have in the other screen shot and not use “apply damage” events, that works too, probably for this purpose you don’t need the added functionality of the “apply damage” function. In that case screen shot where you are creating the health bar widget and where you are subtracting health. Maybe the video wasn’t clear enough on that but the basics are all there. What you need to do is create the reference “path” from the blueprint with the line tracing to the widget, to then pull the progress bar out and set the percent. I see you tried doing my thing in the last screen shot, difference is I used a function so you need to call it (it is more efficient that way) BUT if you just put your binding back in the code you have just made without the damage events should work fine. At least that’s what it looks like to me. You have done 2 different approaches. I am pretty sure I can fix either one for you but I am getting confused on which one you are doing now so choose one and let’s stick with it.

  1. You have not put anything into the base damage on the “apply damage” node, without something there it won’t fire
  2. Even if you put a value in for base damage, you have yet to connect that to anything that will affect player health. As I mentioned before, “Apply damage” and “Event Any Damage” or “Receive Damage” events DO NOT automatically adjust your player health. You still need to script the logic for that.

the first picture below shows a simple way to setup health to be decreased when taking damage. basically you have a float that represents health and on damage you get the health variable and subtract the damage then set the variables value. the second picture shows a good way to setup the binding for the healthbar. the way you currently have it where your dividing max health by current health wont work, if anything you should be dividing current health by max. the goal when using a progress bar is that you want all you values to be between zero and one. for example in your current setup if your character has a max health of 100 and a current health of 10 then 100/10=10 which is out of the range of the progress bar, so it will look like the bar isnt working. if you have current / max then you would have 10/100=0.1 which is in the needed range and would result in the bar being a tenth full. in the example in the picture i used a normalize to range node which does basically the same thing, it tells you what the percentage is of the value between a min and max number. simply put it gives you the percentage you need in the right form.

Didn’t even notice the backwards dividing haha I was too focused on getting something put in the base damage and having the OP script some logic off those events, good catch

It works. I love both of you, thanks very much guys.

I think these are the screenshots you were looking for, thanks for your patience.