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!
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.
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
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.
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.
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.