Animation + damage

Hi everyone, I’ve been following various tutorials about health decreasing when the character stands somewhere and also about applying damage. However, I cannot find one where they explain how to apply damage with an animation (punching montage for example). I want my AI to have it’s health decreased while punching it with my hero until it dies. Can someone explain to me how I can do this?

Hello Sahirasahara,

The easiest way to do this would be to add a socket to the punching character’s fists and attach a volume to it. You can then calculate the damage based off of an OnBeginOverlap event or something of the sort.

Thank you for your answer, I found a solution :slight_smile:

In fact I still encounter a problem, my damage system works but only when capsules collide, could you give an example of what you said with the sockets and volumes? I don’t know how to calculate the damage based of an OnBeginOverlap.

What in particular do you need assistance with? You should be able to create a socket on the skeletal mesh that is attached to the hand. After that, you can create a collision box, sphere, or any collision shape that you want and attach it to the socket.

As far as calculation, it should work the same way. You can use OnComponentBeginOverlap from the collision volume that is attached to the hand and use the OtherActor or OtherComp pins to Cast To your enemy blueprint or it’s collision component, depending on which you choose. From the result of that cast, you should be able to deal the damage there by subtracting from the health or calling a function you have set up to do this.

Things will be more complicated if you’re doing damage overtime, multiple hits, or being able to hit while moving but a few booleans and/or timers should be able to sort those out.

Ok thank you for your answer, I finally got everything working :slight_smile: . It didn’t work before because I didn’t understand what slots were for.

can yo u send me a picture for that all what you did for it to work? i have same problem and i cant understand without seeing what you did