# Emergency, Healt and Damage

**URL:** <https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [May 23, 2024, 12:48pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137 "2024-05-23T12:48:36Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [May 23, 2024, 1:52pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/9 "2024-05-23T13:52:30Z")

</div>

- it’s not safe to rely on == with floats. Try:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/8/6/c86f86d73cd1b9dc5e01af12cd860bc9df67b5ee.png)

Ideally, _also_ check it it’s below zero.

* * *

- I am a bit confused by the script, though. You seem to keep health in a character but attempt to destroy the BP you’re showing.

- also, you’re casting the Controller to Pawn (?), which makes no sense and will never work - the cast probably fails - could you double check?

- if this script is already in the Actor we want to destroy once its health goes below the threshold, there’s no need to cast, just call the function directly

- and lastly, you call it on Begin Play - how is this supposed to count health if it only happens once, when the actor is spawned. Did you mean to hook it to a node that triggers when damage is received?

* * *

So yeah, lots of things are going on that I do not understand. Under regular circumstances, the player character would have something along the lines of implemented:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/7/1b7a43a48aca941339cbc78ab779eb4a27bf63ff.png)

I am ignoring the `Damage Type` pre-processor which should be probably involved in all this. It might be too early for this.

---

_[View the full topic](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137)._
