# 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:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BigCambonz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BigCambonz](https://forums.unrealengine.com/u/BigCambonz)\
**Post date:** [May 23, 2024, 12:48pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/1 "2024-05-23T12:48:37Z")

</div>

What is the node or logic for calling the Apply Damage node in a loop? Thanks in advance

 ![Immagine 2024-05-23 144419](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/5/f953ef8c8582b7179acc6dd83c5deca2d776129d.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:** [May 23, 2024, 12:54pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/2 "2024-05-23T12:54:40Z")

</div>

> [@BigCambonz](#):
>
> calling the Apply Damage node in a loop

Could you clarify? Because it sounds as if were looking for the `Loop` node. Do you want to make the damage _tick_ - be applied, let’s say, 5 x per second? A loop node will not help you here.

---

<div class="post-metadata">

**Author:** ![BigCambonz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BigCambonz](https://forums.unrealengine.com/u/BigCambonz)\
**Post date:** [May 23, 2024, 1:04pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/3 "2024-05-23T13:04:17Z")

</div>

Sorry if I expressed myself wrongly, I mean that when my character is in contact with capsule collision always receive damage

---

<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:08pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/4 "2024-05-23T13:08:10Z")

</div>

> [@BigCambonz](#):
>
> I mean that when my character is in contact with capsule collision always receive damage

This is still unclear. What does **always** mean? I assume you mean continually - is that so? How often then?

* * *

It’s not a good idea to base on a framerate since different end user machines would apply varying amount of damage. The most standard way is to use a `Timer`, if you fire it 30x per second, it will be pretty much indistinguishable from continues damage. You could even apply if once per second and interpolate the result.

---

<div class="post-metadata">

**Author:** ![BigCambonz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BigCambonz](https://forums.unrealengine.com/u/BigCambonz)\
**Post date:** [May 23, 2024, 1:11pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/5 "2024-05-23T13:11:17Z")

</div>

yes i mean continually, but i will try to set a 30-second timer like you said.

---

<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:12pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/6 "2024-05-23T13:12:44Z")

</div>

This would deal 10 damage 5x per second - so 50dmg per second:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/7/2/57271fc362b6bf19508b17080b9d3e96bb17b259.png)

* * *

Also, no need to cast here. 😇

---

<div class="post-metadata">

**Author:** ![BigCambonz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BigCambonz](https://forums.unrealengine.com/u/BigCambonz)\
**Post date:** [May 23, 2024, 1:14pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/7 "2024-05-23T13:14:29Z")

</div>

Once again Thank You

---

<div class="post-metadata">

**Author:** ![BigCambonz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BigCambonz](https://forums.unrealengine.com/u/BigCambonz)\
**Post date:** [May 23, 2024, 1:41pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/8 "2024-05-23T13:41:24Z")

</div>

I am currently working on a 2D platformer, but I encountered a problem. I created the HealtBar logic, but when my character has zero life, the Destroy Actor node doesn’t kick in, I don’t know why. Do you have any suggestions on this?

 ![Immagine 2024-05-23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/6/6269267ac26fd6d5cd664bf3cc3719e9889534bd.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:** [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.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 22, 2024, 1:53pm UTC](https://forums.unrealengine.com/t/emergency-healt-and-damage/1869137/10 "2024-06-22T13:53:03Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
