Hello fellow devs, in this thread I'll show you why it's important to use Point Damage using my plugin and I'll show you some different ways to setup this process correctly. In this tutorial we'll analyze different scenarios of gameplay such as FPS, Melee TPS, VR, Physics Simulation (using hit event)... Fist of all we need to understand why it's importat to use Point Damage.
Damage System and Hitboxes
When you're working with skeletal meshes, you'll already know, collisions are managed inside the Physics Asset. Here you can assign "Hit Boxes", or "Bodies", to each bone of your skeleton. This way you can graphically setup an hitbox structure which will be also used for physics simulation. The GoreSystem Plugin take advantage of this feature.
Using names assigned to these "Bodies", this Gore System will allow you to create a list of detachable limbs and set their specific variables (ie. sounds, particles, health, ...). This way you'll not need to setup additional actor components to create hitboxes, your Physics Asset will be the only thing determinating your damage system.
For example, you could decide each damage received to the head will be multiplied by 2:
Why you should use Point Damage or Radial Damage
Now we know the system needs a bone name to correctly process the damage information, so if we take a look to the 3 different default ways of applying damage in UE4 we can notice the only one who can't return a bone name variable is the simple "Apply Damage", which will call "Any Damage Event".
Events
Functions
Point Damage Hit Gathering Methods
There are several ways to gather information about hit when it comes to point damage. Most common practice are using Traces or Hit Events.
Traces
Usually used when no physics simulation is involved, given two points the engine will trace a shape (could be line, box, sphere or capsule) and will return some informations if hit happen. These informations include "Hit Bone Name" (If traced against a Skeletal Mesh, this is the name of the bone that was hit.) which can be used for our purpose.
Hit Events
This method is really similar to Traces but it involves physics. Once a component, simulating physic, hit another object and its "Simulation Generates Hit" variable is set to true, it will call the "Event Hit" or "Event On Component Hit". You can find a clear example inside the default FPS Template from Epic (BP_FirstPresonProjectile).
Radial Damage Automatic Hit Gathering
The "ApplyRadialDamage" function will automatically trace a sphere around the given origin and will call the "RadialDamageEvent" on all the hit actors.
Although this method is completelly suitable for our purposes, I suggest to use "ApplyPointDamage" instead because I planned to release a new function dedicated to Radial Damages, caused by explosions for example.
This is also useful for aoe damages, infact the "ApplyRadialDamage" will damage all the actors inside the "DamageRadius" (see screenshot above).
Work-around to use Apply Damage anyway
There could be different ways to find a work-around to adapt "Apply Damage" to this plugin. One exaple is the following where a function will find the nearest bone to damaging actor using the default UE4 FPS Template's bullet.
Make sure "DamageCauser" pin is filled with the bullet actor reference (see below for more info on limitations)
I created a pure function which will return the nearest bone to a certain actor. Obviously this method has huge limitation but could be suitable for certain parts of your gameplay.
Variables with suffix "L_" are local variables!
Firing the physical bullet to our character will now apply damage to correct bone.
Although this is a good idea, it has huge limitations, you'll need to be sure the actor applying the damage is infact near the actor damaged (ie. physical bullet, granade, ...) otherwise the function won't be able to find an accurate nearest bone name.
Applying damage with trace using whis work-around will return an incorrect value
Edited by: Klian