How to play a UI animation off of damage from an outside blueprint?

I have UI animations made in a widget blueprint that is cast to my player character. I want to play these animations when I take damage (an overlap trigger volume that detracts from my health value every second). I made a little red flash animation thats just changing the opacity and color of the default white image the ui widget gives you. Which blueprint do I have to edit and what do I have to cast to to accomplish this? Thanks.

You should have an AnyDamage event in your Player Character blueprint. You should also keep a reference to the Widget that you added to the screen (which includes the health bar). I’m gonna assume you do that in your player controller, but if you do it in your player character that’s fine.

You should also have a custom event in your widget blueprint that plays the animation you want (PlayAnimation node).

When the AnyDamage event fires, you call the custom event in your widget blueprint, using the reference you saved when you added it to the screen, and it should play the UI animation you configured.

If you’ve got any further questions let me know :wink:

Hey, thanks so much for the reply. I’m at work right now so I can’t try this out immediately but I wanted to ask if I have an animation for the value going up AND an animation for the value going down, would this method still work? Thanks.

Apologies, I tried to respond to this earlier but I guess it didn’t go thru. The thing is, I have 2 UI animations for the health value, one for damage and one for healing. I would think AnyDamage would only allow the use of one of them?

Well, the AnyDamage event is called when you call the Damage function of the character blueprint (from another class, for instance).

You can simply call the function with a negative value to add health to the character, and on the AnyDamage event check if the damage is positive. If it isn’t, play the healing animation instead of the damage animation :wink: