# Help needed in figuring out how to damage enemies

**URL:** <https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 30, 2022, 4:31am UTC](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454 "2022-09-30T04:31:02Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![HungryMoogle](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hungrymoogle/32/1194510_2.png) [@HungryMoogle](https://forums.unrealengine.com/u/HungryMoogle)\
**Post date:** [October 5, 2022, 6:59am UTC](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454/21 "2022-10-05T06:59:48Z")

</div>

I’m completely lost. 😖

I’ve been spending hours upon hours trying to figure how to either fix my current setup or completely overhaul it but to no avail.

It doesn’t help matters I getting contradictory advice on how to handle damage; uses interfaces! Don’t use interfaces! It just it makes all the more confusing and frustrating for me to try and figure what action I should take.

The problem is its not just damage that needs to be taken into consideration, its visual & sound effects, its how the enemy reacts to the hit i.e. the enemy reeling backwards from a melee attack, squashing from having the player land on their head etc. is why I wanted to split the damage process into three main categories: the attack’s initial collision check with the enemy, followed by the effect the attack has on the enemy such as whether or not the attack does damage & how much, as well any necessary audio or visual effects. And lastly, is the enemy’s response to the attack like the stuff I mentioned above about knockback or the enemy squishing.

Yes, its a lot back-and-forth communication but I don’t know how else to do it, as I want the attack details (damage, VFX, SFX, etc.) to be in a single location that all enemy and other interactable object blueprints that are connected to, so that way I don’t have to make changes to hundreds of individual blueprints if I need to change something about an attack. That single location I figure should be the player character blueprint, the only other area I can think of would be the parent blueprint for enemies but I’d also have to take any non-enemy objects that an attack might interact with into account as well.

I just can’t come with an alternative setup that meets my needs. That’s left me with trying to fix my current setup but I still haven’t been able to fix the target issue:

 ![target_help](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/6/0f6752f79f5f7ad8e1c57bcf7efdfff4cfc5dfc3.png)

I mentioned it multiple times but no one so far has actually addressed how you fix problem. As I’ve said a number of times already, the interface message-or-whatever-the-proper-name-for-it-is needs to be directed towards the player character blueprint but I haven’t been able to figure how to do that.

Is it simply not possible to get the player character blueprint to target particular interface message? If not, what else can I do?

---

<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:** [October 5, 2022, 7:27am UTC](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454/22 "2022-10-05T07:27:42Z")

</div>

> [@HungryMoogle](#):
>
> I mentioned it multiple times but no one so far has actually addressed how you fix problem. As I’ve said a number of times already, the interface message-or-whatever-the-proper-name-for-it-is needs to be directed towards the player character blueprint but I haven’t been able to figure how to do that.

Not true at all. ;p You are the one who walks in circles.

How do you know what the bat hit? Where is the Overlap that triggers it? Where is the reference to the target - the player?

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

- _Other Actor_ - is the actor the overlap detected. If you’re using inheritance (that you _never_ explained) you can do in the parent (above) or override in the child:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/5/f954df112619542209f7dd8b694754786251f651.png)

And message Other Actor with either Apply Damage interface or your own custom Interface as shown in the [1st pic of post](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454/8) above. is _precisely_ what you asked for.

* * *

Create a new project, follow those 3 steps:

> [@Help needed in figuring out how to damage enemies](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454/18):
>
> Essentially, there are few elements to a working interface: sending a message to the correct actor: [image] that class needs to implement that interface, and function / event: However: I do not see a point in doing . You’ve already sent a message, why bother with applying damage? Add data to the interface instead. Not saying there is no point or that it wouldn’t work, just that I am not seeing it wink You may have your reasons, ofc.

Use breakpoints:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/4/5c4d6112777d41a9b89704a0404b4423afd40ee5.png)

And debugging to observe how the data flows. Once you can get it to work and understand in a clear project, implement the same method in your own.

Good luck!

---

<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:** [October 5, 2022, 7:32am UTC](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454/23 "2022-10-05T07:32:45Z")

</div>

It it possible that you simply never added an input to your interface function?!

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/4/d/74d0c0e8bb552f0e0b274756612bc521d21d741e.png)

vs

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/f/2/cf278cbb785096380979b446e6c230a3893c3b22.png)

The interface can move any data:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/a/41a35d19e06deff11888f06efa13758f51d4b4b6.png)

Specify the inputs and outputs at the bottom.

* * *

And finally, perhaps there’s confusion regarding how _regular_ functions work:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/1/6811cc6d142b03feacabc5ed25740505537c0d8a.png)

We call a function, pass the reference and call the interface function.

---

<div class="post-metadata">

**Author:** ![HungryMoogle](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hungrymoogle/32/1194510_2.png) [@HungryMoogle](https://forums.unrealengine.com/u/HungryMoogle)\
**Post date:** [October 9, 2022, 5:40am UTC](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454/24 "2022-10-09T05:40:14Z")

</div>

Okay, I think I’ve finally managed to figure out a damage system for enemies that works for my interests, more-or-less.

_Player blueprint:_

 ![basic_hit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/b/68bf094b43df1f23da6bcf3a0f3d3a4d5e5360c2.png)

_Enemy parent blueprint:_  
 ![basic_collision](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/d/5ade1a540d703116cacd48c4878e5d3c32a8a7be.png)

_Enemy blueprint:_

 ![basic_collision_2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/0/9b07a51279e1cc5755157ea9b81ac99d6f510a02.png)

Unfortunately, customizing sound effects for the player’s attack based on the enemy or object the player hits had to be sacrificed for the sake of streamlining the entire damage system. I was thinking of looking into actor tags as a possible way of dealing with issue but otherwise everything appears to work, so I guess that’s everything for now.

Thanks for all the help!

---

<div class="post-metadata">

**Author:** ![Astaraa](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/astaraa/32/1194560_2.png) [@Astaraa](https://forums.unrealengine.com/u/Astaraa)\
**Post date:** [December 1, 2022, 2:53am UTC](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454/25 "2022-12-01T02:53:12Z")

</div>

A little late but…  
You don’t need an interface because `Apply Damage` accepts a basic actor, such as “Other Actor”. Then just use `Event AnyDamage` in the enemy character blueprint.

You can play sound fx right there `On Component Begin Overlap`.  
Check if other actor is an enemy (get class == enemy blueprint class), and if not break `Sweep Result` and use `Surface Type` to determine what type of surface was hit.  
I’d use `On Component Hit` but overlap will work as well.

[Previous page](https://forums.unrealengine.com/t/help-needed-in-figuring-out-how-to-damage-enemies/659454.md?page=1)
