How to Make The HUD Change Based on Damage Received

This is something that I was wondering, because I created a health system and it works perfectly. I’ve finished working on my basic HUD, but I wanted to add some interesting bits of polish to it that makes it change based on taking damage. I already have my HUD set up to subtract health, however what I’m really interested in is making the player icon in the upper left change whenever you take damage. I assume you have to use a Widget animation? This is what I have so far:

So, I’m not even sure if this is the right way I’d go about having the animation play out, since I’m not familiar with the way you check if the player takes damage.

https://forums.unrealengine.com/attachment.php?attachmentid=142340&d=1495713547

And this is the animation in question. Basically what it does is whenever the player takes damage the player’s icon, very quickly, changes to red and back while also changing the player’s icon a different graphic entirely.

https://forums.unrealengine.com/attachment.php?attachmentid=142341&d=1495713683

Example of what I mean: As you can see the player graphic completely changes to a version that shows the icon flinching and turning red, however, I am not sure how exactly you go about doing this in the Widget editor and in blueprints.

No damage taken:

https://forums.unrealengine.com/attachment.php?attachmentid=142343&d=1495713822

Damage taken:

https://forums.unrealengine.com/attachment.php?attachmentid=142342&d=1495713733

Problem, how would I go about setting the widget as a variable? I already have it updating the health in the 1st screenshot:

I’m not quite following you here, as I already have the widget displayed to the viewport, it already has the ability to update the health bar, but the one thing I’m not quite getting is how you’d store the widget as a variable. What I mostly want to do is make the picture I showed animate based on the damage taken, and how I’d change the picture of it.

When you CreateWidget, drag off that blue pin, and promote to variable. then later, you can check if that variable is valid, and if so, you can call its functions or edit its variables through that reference variable.

is this challenge solved or is it still on going?
i am having the same challenge so im hoping someone can anwser this.
kind regards,
zaftan

I might be missing something here but if you’re already passing information to the health bar I’m assuming you have a reference to your HUD from your character? Why not just call a custom event/function at the same time to play the animation and set it’s play mode to Ping Pong?

If I’m not understanding you correctly sorry, but might I suggest checking out this video from the Twin Stick Shooter tutorial.

https://docs.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1gb5sdygbSiEU7hb0eomNLdq/Wwa0zwkYUeQ/index.html