x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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. :)

Here is a youtube link to show the problem in action: [https://www.youtube.com/watch?v=oGn9sJqb7Yg]

Product Version: UE 4.18
Tags:
more ▼

asked May 17 '18 at 01:23 PM in Blueprint Scripting

avatar image

EdgyYasuoMain
1 1 3

avatar image Nebula Games Inc May 17 '18 at 03:10 PM

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.

avatar image EdgyYasuoMain May 17 '18 at 06:16 PM

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.

progress.png (8.8 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

https://youtu.be/BdARbvNrvQE

more ▼

answered May 17 '18 at 06:34 PM

avatar image

Nebula Games Inc
5.4k 28 9 15

avatar image EdgyYasuoMain May 18 '18 at 12:13 AM

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.

avatar image EdgyYasuoMain May 18 '18 at 12:37 AM

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

missing-target.png (133.7 kB)
avatar image Nebula Games Inc May 18 '18 at 01:05 AM

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.

alt text

alt text

alt text

damage.jpg (115.1 kB)
damage-2.jpg (127.8 kB)
damage-3.jpg (110.9 kB)
avatar image Nebula Games Inc May 18 '18 at 01:18 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

getpercent.png (101.4 kB)
damage.png (229.5 kB)
more ▼

answered May 21 '18 at 08:35 AM

avatar image

EdgyYasuoMain
1 1 3

avatar image Nebula Games Inc May 21 '18 at 03:38 PM
  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.

avatar image ThompsonN13 May 21 '18 at 03:58 PM

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.

alt text

alt text

capture.png (54.3 kB)
capture1.png (90.6 kB)
avatar image Nebula Games Inc May 21 '18 at 04:12 PM

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

avatar image EdgyYasuoMain May 22 '18 at 08:23 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question