Bind variable from another actor to PROGRESS BAR?

All i’d like to know is how to bind a float value from ANOTHER Actor, TO MY PROGRESS BAR. any help will be highly appreciated.

i tried doing this but it didn’t work.

Can you be more specific ?
What do you mean by “bind float” ?

Function you did just get damage from Zombie class and return it.

I have a zombie blueprint. That zombie blueprint has a float variable. When i hit the zombie, it decreses the float all the way down to 0. Now in the widget blueprint that contains the progress bar i wanna use, i create a binding for the progress bar so i can add a value to it. i would like to access that variable from my zombie blueprint and assign it to be the value of my progress bar. That way, when i hit the zombie, the bar will decrese and act like an Enemy Health Bar…

All i wanna know is how to access that variable in my zombie blueprint and assign it to my progress bar value.

Your enemy health bar needs to be passed an instance of the zombie, either through a method, or by just assigning it to a member variable on the widget blueprint. Now, you have a member on the widget you can inspect to see what the zombies health is.

It looks like you’re close from your screenshot, all you need to do have someone be responsible for assigning the instance of the zombie to the Blueprint member, like maybe the player controller could notify the UI when his active target changes.

Cheers,
Nick

How do i create a member variable on my widget blueprint?

and can you give me an exact idea on how to add an instance of the zombie to my blueprint? because from what i know, i can only add instances of things that are in the level because you have to select them in order to add the instance. So i’m pretty confused when it comes to widget blueprints…

I Can cast to my player character and was able to get the float from him and make the progress bar work. My zombie blueprint is of character class, and when i use “Get Player Character” and get the variable from HIM it don’t work… but like you said, there are many ways to go about this. i just don’t know how lol How do i add the instance to the variable that i made?

You add member variables just like you do to any other blueprint, the big [+ Variable] button on the left in the graph view.

What is your plan for identifying which zombie to show the hp bar for? You can either scan the world for the current zombie, or pass the player controller to the UI and have them do it, then just have the UI sniff the zombie target of the player controller. Someone has to be scanning the level for active zombie actors. You could do ray casts to get the zombie under the cursor, or do it based on last zombie damaged with events, stuff like that.

My current system is just to test if the health bar actually works. I send a raycast everytime i left click on the zombie

and everytime i hit the zombie, i add the widget to viewport with a “DoOnce” and it decreses the float variable by 0.10 untill it reach 0 wich than destroys actor (Or when i actually add a rigged character, he’ll ragdoll) removes widget from viewport and resets the “DoOnce” back to the starting so it can be used again.

And it’s actually just me, i don’t have a team lol so i would have to set up everything, but i’m fine with that.

And what IS a member variable? What would i do to make a variable a “Member” variable. I Can’t find a member variable in the variables list.

Is this how i create a member variable? how do i make an instance to the zombie?

Hey, i got it to work! I Did like you said and have the player pick the target for the zombie and everything works fine! but now i have another problem… it only works for THAT zombie that i pick as the target. how do i make it so that the progress bar works with all zombies of that zombie class so that every zombie i attack will affect the progress bar or something

Great! You want the progress bar to sum all their healths, and then divide by the sum of all their max healths? Just call, i think the node is Get All Actors of Class? something like that, then access the respective bits of data, add it together and then divide. If instead you want a single target progress bar, but that works with all zombies, just have the player controller change the zombie variable each time you attack a zombie so that it shows the health of the last zombie attacked.

Get all actors of class is array based. i don’t know exactly how to use that. Any way you can give me an example or a better explanation? cause i’m kinda confused haha

What I would do, in your position, is to set an array of type ZombieClass in your level BP. When your Zombies are created or destroyed, add/remove them from the array. In your UI, get a reference to the array in your UI BP, then do a for each loop to get all their HP values.

Alternatively, if this is something that will be happening across multiple levels, you could put the array in the Game Instance BP. Up to you.