My Boss Character's Health Won't Go Down! Help!

Hey guys! I’m going to try to not make this a novel and keep it as intelligible as possible, but I’m really at a loss and there’s a lot of information in there so here goes nothing:

Essentially, we’re making this game and I’m trying to make the UI for it. As part of the UI, I’m trying to display the characters’ health on health bars that work in percentages.
I managed to make the game’s main character’s one work perfectly fine, like so:

The character has 300 health, you see. That’s a part of the Widget graph I’m showing. The character’s blueprint part that takes care of health looks like this:

Essentially it has a base of 300, and whenever he makes contact with a source that causes damage, it received the value of that damage, deals it, then goes back to null until new damage is applied. Following this, and the first picture, the health bar works perfectly fine.

However, when it comes to the boss, nothing works.

It’s based on the same model, and I’ve tried connecting many types of sources (you see them on the left) without success. The health bar is always at a 100% without fail, and even when the monster takes damage and the game acknowledges it, the health bar just won’t go down like the main character’s will.

The boss has his own Blueprint as well, like so:

He has 1000 health, and takes 15 damage per hit, but his health bar is permanently full all the time. For some reason, casting to the boss’ blueprint fails all the time no matter what I try and since the same logic works in the main character’s hands, I’m at a complete loss as to why this isn’t working. I’ve lost 5 hours over this “simple” thing now, and I’m almost ready to give up, which I can’t afford to do. :confused:

Anyone got an idea? If anyone’s got any questions to try and clarify it let me know I’ll do everything I can to provide info! Thank you!

Sorry for the novel and for the possibly simple issue, I’ve picked up Blueprints only very recently. I hope someone can help!!!


Well, if the issue is caused by the cast failing, you just have to reference the correct actor when casting…

The reason none of the nodes you tried didn’t work is because the boss isn’t any one of those. It isn’t the player, or the player controller, etc… So you have to get the correct reference for him. You could “Get All Actors From Class”, choose your boss BP, “get” the array, and then feed that into your cast.


Somehow I haven’t managed to make that work either. :confused: Tried it a few times last night but to no avail… I get what you’re saying though, that it isn’t any of those classes. But our health system is set up as an integer but not as an array so I’m not sure how to approach this. The funny thing is that the game registers the health going down (print string) and displays it from the Boss’ BP, but I simply can’t make it compute in the Widget function I presented. It thinks the health is continually 1000 somehow, I think. Regardless, it simply won’t go down no matter how long we maim it. ^^"

Any alternatives?

What I mentioned didn’t work?

I just set up a project and made it to be like I assume yours is, and it worked fine…

Your GetHealth for the boss is for a progress bar bound to percent isn’t it?

Yes it is!
As mentioned, this is boggling to me because it works in exactly the same way as the Player’s. What you said to me makes sense; the Boss isn’t a Player, A player Controller or a PlayerPawn, so it can’t cast the information. Makes perfect sense to me (and makes me feel a bit silly ^^" but I’m very new at this, so I expect to look dumb a few times haha). I’m wondering how you set yours up so it worked?
I tried setting the idea you gave me, but I’m really not sure I understand how arrays work (even while reading the documentation, somehow… :/) and since the health value of the Boss (in its own BP) isn’t part of an array either, I was at a complete loss.
Did you set up your set using the pictures I sent with my issue…?
Just trying to understand, I am so ready to find the solution to this now haha!

It is understandable that the whole Blueprint system can be a bit confusing at first. There is a lot of documentation out there to help you out with most everything with a bit of research though. Vanlacke’s solution is sound, here is a picture example of how it should look like when casting to your Boss Actor.

For practicality though, you should get into the habit of making references that you plan on using more then once into variables for a more efficient work flow.
Once you have a variable referencing your actor, you can cast to it without using the get all actors of class node.

EDIT: My bad, you should use an IsValid? Node on the second part to avoid any issues. You don’t need one to set the boss reference since you know the boss is present in your level at that point. If you know that this won’t get called after the boss get’s destroyed then you don’t necessarily need to use this node. Also I am not using Cast To node in these examples as you are calling the actor reference from it’s specific index. You would use the Cast To node in the case of an overlap result or Hit result to return the specific actor in question.

Further more, Get All Actors of Class > Get 0 means that in part 1 you find all actors of class and part 2 that you specifically call actor of index 0 which is essentially number 1. Useful when you have only 1 actor of class present in level, like boss’.

Hey Mortusnyte! Thanks for the extra help, I really appreciate you taking a moment to look at my issue! ^^" I’ve absolutely no doubt that Vanlacke’s solution is sound (I hope that’s not how I came across haha), I just feel like maybe the details elude me and I lack the needed understanding of arrays to make it complete. I did look at the documentation though, and I’ll look at it a bit more after this, because I want this to work! It just really seems really hard to grasp for me. I’m so sorry for the troubles!

You seem to have created a custom event, though, instead of placing it inside a Widget function? Is that in the Level Blueprint instead?
Also did you just set up the “GET” from the out actor and then “get Health” (simple integer) from the BossBP? (because I’m assuming the “Boss” in the Get All Actors of Class is the Boss pawn’s own BluePrint?)
Because in the widget function graph, I try to create the “get Boss Health [integer]” but once it’s created I simply cannot connect it to the GET at all…

This is all I did, only difference being I used a float instead of integer. My damage setup is just simply when the boss is clicked he takes damage. Keep in mind like Mortusnyte mentioned, this solution would only really be suited if you have only one “boss” up.

And here’s a vid… This is what you’re trying to do right?

Yes! Correct, that’s what I’m trying to do! :slight_smile:
It’s true the only difference is that you click and he takes damage automatically, where mine has to be impacted by a projectile, but it seems like it’s fairly the same thing. Seems like this could work.
I am not set up to be able to test it out immediately, since I’m at work, but I’m taking the occasion to stock up on information and methods so I can try as many as I can the second I get out of here and let both you and Mortusnyte know asap!
So just to make sure; your “Boss” is a different, separate entitiy BluePrint from the MainCharacter’s (like mine), and you didn’t actually create an array to make this work? Or did you create some sort of array in the Boss BP?
I guess in this situation, I’d be using your Cast to Boss > Target-BossHealth [Get Boss Health] > /1000> Return value to make it work?
There is indeed only 1 “Boss” in our project. One MainCharacter, One Boss, and a few destructibles across the map (objects, not characters). You think that’d work?

Yeah I set this up in my LevelBlueprint for example but the same goes for within your widget. And yes I dragged the Get node from the Array reference of the Get All Actos of Class node which gives me a reference to the Boss Actor which is an Actor Class BP that I created. and I get Health from the Get Node which pulls the variable from my Boss Actor BP. The Get only works for the actors you cannot Get a variable fromt hat noe since you can simply drag out your variable unto the graph and select get or hold Ctrl while dragging out to get. In your case you would want to Get All Actors of Class > Get > Get Boss Health plug the Get Boss Health into your Widget Boss Health Variable as SET and plug that in your … You know what I have a Match-3 project that calls a variable from an actor class into my widget to display a Percentage bar, I’ll get a picture of that

Ok in this first image, you would set this up in the event graph of your Widget most likely. I needed to bind it to a text in my Widget so I set it up in the bind section of that in my case.

Then you use the variable that you created in your widget to set the percentage bar. But in practice you should be able to do ALL of that exactly as you did with your character health bar in one simple graph but use the Get All Actors of Class to get your boss reference instead of the Cast To node. Ahh I made this sound way more complicated then it is haha Might as well go vote for my project now! Thank you! Trello. You need to log in to vote :slight_smile: Hope I was able to help some lol

If I can’t make it work immediately, I’ll also try to bring a gif or vid or something of the projectiles hitting the boss, console counting damage but healthbar not going down for you of course. I’ll see if I can do that. I hope I don’t have to. xD

Yep, totally separate BP… And no array, not sure where I’d need an array for this but perhaps you have some other features I didn’t include.

Here’s what I did:

  1. Boss BP, with an OnClick event that reduces his health.

  2. Then I have the UMG HP bar that simply grabs the health variable from the Boss BP.

Also, the reason your print works fine is because it’s using the variable from your Boss BP, whereas your HP bar isn’t getting the variable

I got onto my stations, fiddled with the variables and tried to recreate just and that and BAM, it fixed my problem!
You guys are a GODSEND. Thank you sooo much Mortusnyte, Vanlacke. I can now progress with my work!
/tearsofjoy.jpeg :smiley: