How to apply damage to AI?

Hi, I’m having trouble applying damage to the AI when he is hit with the spells that I’ve implemented. I’ve been experimenting for almost an hour now, but it seems like nothing is working. I did have a result where the spells did damage, but when the AI ran into things that also caused damage to the AI as well. I want the spells to do damage, not the other actors in my game…I was wondering if anyone could help me out with this issue? Any help will be greatly appreciated. Here are a few images that will elaborate on my problem.

Thank you for your response, but I’m still having the same problem. :frowning:

First up, your apply damage had nothing selected.

I can not see where you applying damage correctly.

I would get enemy location, then apply damage. Then on event any damage apply that.

I can a quick graph how I would do it and you can convert?

updating ue4, give me a bit

sure, visual help would be awesome!

Var is named wrong, pretend it says health

Sorry for the late reply, just got back home. I’m going to attempt your scripting now. :slight_smile:

Alright, I tired to add a, “line trace by channel”, but there isn’t “out hit impact normal” on the node.

Would you like to try adding collision component to your spell and use ‘OnComponentBeginOverlap’ to detect everyone that is hit by your spell?

The spells are simply projectiles, and I have tried OnComponentBeginOverlap before, but the AI character took health when walking into assets such as barrels and trees. I am very confused with your comment…

I want the spells to cause damage, not and barrels.

I’ve used this approach to my melee weapon and planning to do this on projectiles also since I’m having hard detecting hits with line trace.

Right now, I’m able to call my target AI’s Take Damage function using this. I did need to turn the capsule collision’s on and off at certain though to prevent it from hitting everyone when not attacking.

In any case, what the setup of your combat? real like DMC or something?

I’m still very confused. Would it be possible for you to show me a screenshot of your scripting for your melee weapon or? If not, then is there another way that you could help me?

Here’s my result,

  1. I’ve added a capsule collision to my weapon once the character already has a weapon. I setup its height and radius and turn is enable to ‘No Collision’ in the BP. I have to do this because the weapon, for the first , is not existing. In your case, since your spell has an actor already, you can just simply add a component to it.

  2. Collision is still turned of so even when it overlaps with the target it doesn’t trigger its Take Damage.

  3. At this point, the collision is set to enable via AnimBP.

  4. Lastly, as it hits the target, the take damage triggers since the AI has overlapped the capsule collision. See the log “Ouch!” After then, the collision was disable via AnimBP too.

Sorry for the late reply, I was sleeping. Nothing seems to be working. :frowning: You keep mentioning something about a capsule, but how do I actually add a capsule? I’m very confused with the entire process at the moment. :frowning: Here are a few images that shows you my spells, damage function ect…

It’s suppose to be in add component, capsule collision. But you can use other collisions like a sphere or box. Depends on your preference.

Sorry, I overlooked some parts of your BP. You must have the code for OnComponentBeginOverlap in your Fire.

From there cast the other actor to the AI Character, then call it’s Take Damage function.

Sorry just got back. I just did what you told me, and I’m happy to say that it works! You don’t understand how grateful I am. Thank you so much!