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:
The player seems to be able to inflict damage to objects now, but I am pretty sure this isnt 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 shouldnt 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?
I developed a per-bone sword collision system that takes animations into account.
Here’s a video!
Epic wiki link
#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