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"

Ball blueprint healthbar

Hi there, i am having an issue getting the progressionbar from a health-widget to target the ball from the rolling ball template, and i have tried all the stuff i can think of.

Since the ball is not a character-class, is the progress bar out of the question or is there a way around this?

Any help or clarification would be greatly appreciated!

-Nikualt text

Product Version: UE 4.21
Tags:
problem.jpg (400.1 kB)
more ▼

asked Feb 02 '19 at 02:40 PM in Blueprint Scripting

avatar image

Niku-zan
7 1 1 3

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

whats the balls object type? is it an actor or a pawn? if its a pawn then the method you show could potentially work, that is aside from the get all of class which is a bad way to go about this. also where is the healthbar being created? if you create the healthbar from the ball bp then you can create a variable in the widget and pass along a reference when the widget is created.

so the simple answer is yes you can have a healthbar with any actor, but to decide on implementation more info may be required. I dont have that template installed atm so i cant exactly build it for you.

more ▼

answered Feb 02 '19 at 05:22 PM

avatar image

ThompsonN13
8.9k 30 8 20

avatar image ThompsonN13 Feb 02 '19 at 06:26 PM

ok so i just installed the template and tested. two things with your current setup: first your math is backwards if your trying to get a 0-1 value, your dividing max health by current which will give you a number between 1 and infinite. the second thing here is your using a binding for changing the color and opacity, if your intent is to control the color of the bar by the health amount you are going to want to define the channels which are affected.

below are two examples of how you could handle changing the color based off of the health variable. the first method is basically what your doing but we define which channel to control. the second method uses the health as a alpha to lerp between two linear colors.

alt text

capture.png (237.9 kB)
avatar image ThompsonN13 Feb 02 '19 at 06:29 PM

o yea and in response to your original question theres also a node "get player pawn" which could be useful to you.

avatar image Niku-zan Feb 02 '19 at 06:32 PM

The ball i am using as a character, has a"Pawn" - Parent class, and the healthbar is created as a seperate Widget as it's own blueprint.

I did not know i could create a blueprint within an other blueprint? (care to comment on this?)

I have tried all the possible connections from the picture above, but it always shows an error of one sort or another :(

avatar image ThompsonN13 Feb 02 '19 at 06:45 PM

The ball i am using as a character, has a"Pawn" - Parent class

its a pawn not a character. i realize your trying to say character as in the object possessed by the player but character is a actual technical term so becomes confusing.

I did not know i could create a blueprint within an other blueprint?

its not really creating a blueprint in a blueprint its create a blueprint actor instance from a blueprint. basically i was asking where you are creating the widget as in where are you using the create widget and add to viewport nodes. i wrote healthbar as short for healthbar widget, i should have been clearer.

I have tried all the possible connections from the picture above, but it always shows an error of one sort or another

what errors are you getting? i tested the script as seen above and it works without issue. do you have the bindings set properly? did you deviate from whats shown? if so how? whats your health value set to?

your response here in this last section is the equivalent of saying "it didnt work". provide some detail for us to work from, otherwise all we can say is try again and theres a problem elsewhere.

avatar image Niku-zan Feb 02 '19 at 06:50 PM

Ah sorry about that, i will refrain from calling it a character from now on (still a novice student here, so thanks for the heads up)

I wrote my reply before the page updated properly, so i havent gotten the chance to test them out properly yet!

However, from the guide i was following they used two float-variables (max health and current health) while you have only one, so i am unsure if the process is affected by this?

and to be clear, i am only trying to get a basic healthbar to work, ticking down upon taking damage like a good old 90's shooter would

avatar image ThompsonN13 Feb 02 '19 at 07:06 PM

alright cool pretty simple then.

they used two float-variables (max health and current health)

ok this is a design choice and i was lazy so no biggie. you have two options here you can either: take current health and divide it by max health to get a 0-1 value OR you can use the normalize to range node which will make things a but more straightforward. oh and in case you didnt know progress bars work in the 0-1 range hence why we use division and such here.

to get a basic healthbar to work, ticking down upon taking damage

for this your working with the wrong binding. to get the bar to decrease upon taking damage you want to be working with the percent binding. go back to the designer page, select the progress bar, and in the progress section look for percent. the binding function will look basically the same but the return node will have a float input instead of a color struct. example binding shown below.

alt text

capture.png (119.8 kB)
avatar image Niku-zan Feb 02 '19 at 07:13 PM

Aaah, ofcourse i've been working hours on the wrong binding :') (how typical)

Thanks a lot, that seemed to do the trick, and your replies were very insightful :D

(comments are locked)
10|2000 characters needed characters left
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