# What is the proper way to inflict damage using sockets?

**URL:** <https://forums.unrealengine.com/t/what-is-the-proper-way-to-inflict-damage-using-sockets/279562>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 3, 2014, 6:03pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-inflict-damage-using-sockets/279562 "2014-04-03T18:03:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brokenpoly](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brokenpoly](https://forums.unrealengine.com/u/brokenpoly)\
**Post date:** [April 3, 2014, 6:03pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-inflict-damage-using-sockets/279562/1 "2014-04-03T18:03:33Z")

</div>

Hi guys & gals!

I am pretty new to character scripting in UE4, so I was wondering what`s the best/easiest way for my character to inflict damage onto other objects or enemies/pawns? At the moment, I got a character with a simple melee attack animation in my scene and after playing around with sockets and blueprint, this is what I got:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/6/ed60178a30d62d4ef3d9c313162db2cb0670f21a.jpeg "More melee testing, now with damage") ](https://www.youtube.com/watch?v=CQtDdi03ttA)

The player seems to be able to inflict damage to objects now, but I am pretty sure this isn`t the correct way of doing things. First of all, it only seems the damage is inflicted at the location of the socket when the animation starts, and not every frame of the animation. Secondly, I am pretty sure I shouldn`t have to make an “Event Any Damage” event for all the objects I want the damage to be applied to.

Can anyone point me in the right direction when it comes to inflicting damage, both to other pawns and preferably to destructable objects & rigid bodies as well?

All the best,

Roald

Socket on player:  
[https://dl.dropboxusercontent.com/u/1412178/socket.JPG](https://dl.dropboxusercontent.com/u/1412178/socket.JPG)

Simple blueprint setup for objects taking damage:  
[https://dl.dropboxusercontent.com/u/1412178/event\_damage.JPG](https://dl.dropboxusercontent.com/u/1412178/event_damage.JPG)

Character blueprint setup:  
[https://dl.dropboxusercontent.com/u/1412178/character\_setup.JPG](https://dl.dropboxusercontent.com/u/1412178/character_setup.JPG)

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [April 3, 2014, 6:23pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-inflict-damage-using-sockets/279562/2 "2014-04-03T18:23:35Z")

</div>

#Per Bone Sword Collision

I developed a per-bone sword collision system that takes animations into account.

Here’s a video!

Epic wiki link

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

#Summary

you need do simple traces to identify which actor is in front of the weapon

then do a component level trace (see primitivecomponent.h) against the mesh of the character that is found in front of player

you need to do the traces from the weapon in the direction it is moving. Calculate the socket’s normalized velocity (direction) by getting the prev and current socket position

make several sockets along the length of the weapon and trace in the direction the sword is moving

all the above traces are simple

only once you have detected a character in front of sword do you switch to component trace

and you should only do the component trace from the 1 socket where the simple trace connected

multiple component traces can get expensive

Enjoy!

Rama

---

<div class="post-metadata">

**Author:** ![brokenpoly](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brokenpoly](https://forums.unrealengine.com/u/brokenpoly)\
**Post date:** [April 3, 2014, 7:53pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-inflict-damage-using-sockets/279562/3 "2014-04-03T19:53:50Z")

</div>

Hi there & thanks for the reply!

This method seems a tad complicated for my brain, but I`ll see if I can implement it 🙂

---

<div class="post-metadata">

**Author:** ![0vr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0vr](https://forums.unrealengine.com/u/0vr)\
**Post date:** [May 5, 2014, 5:27am UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-inflict-damage-using-sockets/279562/4 "2014-05-05T05:27:22Z")

</div>

A video tutorial would be mighty helpful. i saw Rama’s video demonstration and it was interesting. please show me how you did that.
