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

**URL:** <https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957>\
**Category:** Character & Animation\
**Tags:** health, death, unreal-engine, question\
**Created:** [April 15, 2021, 6:08am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957 "2021-04-15T06:08:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 15, 2021, 6:08am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/1 "2021-04-15T06:08:56Z")

</div>

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.

 ![335945-enemyhealtheventgraph.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/0/8/508d8bcd8dd85466551dc5caead64266e3685f95.png)

 ![335946-image-2021-04-14-230147.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/0/8/008cd6664c0bae2311dbd1869c30f86dfcea03c0.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 15, 2021, 6:38am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/2 "2021-04-15T06:38:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BamaGame](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BamaGame](https://forums.unrealengine.com/u/BamaGame)\
**Post date:** [April 15, 2021, 7:41am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/3 "2021-04-15T07:41:47Z")

</div>

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

 ![335968-anim.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/6/8b632524300f9dda3394519df44877eb5b9a902b.jpeg)

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 15, 2021, 7:44am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/4 "2021-04-15T07:44:28Z")

</div>

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

 ![335969-image-2021-04-15-004421.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/0/e/30ea7063763eaeda767f14f251285588fd4f51e7.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 15, 2021, 8:01am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/5 "2021-04-15T08:01:27Z")

</div>

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

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 15, 2021, 8:06am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/6 "2021-04-15T08:06:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 15, 2021, 8:07am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/7 "2021-04-15T08:07:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 15, 2021, 8:10am UTC](https://forums.unrealengine.com/t/why-does-my-death-animation-not-play-when-the-enemy-has-0-health/481957/8 "2021-04-15T08:10:56Z")

</div>

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