Help needed in figuring out how to damage enemies

I’m completely lost. :confounded:

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:

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?

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

  • 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:

And message Other Actor with either Apply Damage interface or your own custom Interface as shown in the 1st pic of post above. is precisely what you asked for.


Create a new project, follow those 3 steps:

Use breakpoints:

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!

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

vs

The interface can move any data:

Specify the inputs and outputs at the bottom.


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

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

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:

Enemy parent blueprint:
basic_collision

Enemy blueprint:

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!

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.