Why does my death animation not play when the enemy has 0 health?

I have setup a health system where 1.0 means the enemy has full health and 0.0 means they have no health. The value range for the health is between 0 and 1 with a default value of 1.0. Each hit from my sword does 0.1 damage so it takes 10 hits for an enemy to have 0 health. I have setup a custom event that is supposed to update the health, check if the health is less than or equal to 0, and if that’s true then print a TRUE string, and then play my death animation. However, on the tenth hit the enemy does not play the death animation, and the print string does not print anything. So basically, it is not correctly detecting the enemy’s health. I know that the enemy is taking damage because I can see it on the health bar, and a print string shows the enemy’s health decreasing as I damage it. When the enemy takes the tenth hit, it says their health is “-0.0” I’m not sure if that’s normal or if it’s supposed to be “0.0” but I just thought I’d say it anyways.

Your explanation is clear and it looks fine at a glance. We’ll need to see what’s in the Update Health function. Perhaps you destroy the actor there? Perhaps it’s formatting, perhaps it’s a floating point errors.

Hard to tell without seeing what makes the variable be -0.0

I’m assuming it’s below zero but decimals are truncated.

First, check for your animation is valid for your character. after that if it was valid use this I hope it will solve your problem

This is what I’ve got for my update health function. Is it because there’s no return node?

However, on the tenth hit the enemy
does not play the death animation, and
the print string does not print

If you read OP’s message, you’ll notice the print string does not fire. We don’t even get to the animation, judging by the description.

Nah, you don’t need a return. It’s something else. Can you do me a favour? Could you Print the enemy health values in the enemy actor, don’t update the widget at all (for now).

Just Print health when Enemy Dead is called.

Do tell what values you’re getting.

By the way, where and how do you modify that Enemy Health - I though I’d see it in the function but clearly it’s done elsewhere.

I am assuming all the script you’re showing is in the Enemy blueprint, right?

Also, if I change the <= 0 node to < 0.1, it still doesn’t print the string or play the animation.