Here we can publicly discuss about marketplace plugins i produced and you're using for your game. Feel free to open new threads about whatever you want.

Forum Thread
  Posts  
[Tutorial] Apply AnyDamage / PointDamage / RadialDamage (Groups : Klian - UE4Marketplace Group : Forum : [General] GoreSystem : [Tutorial] Apply AnyDamage / PointDamage / RadialDamage) Post Reply
Thread Options
Sep 6 2020 Anchor

DamageTypes 00

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.

DamageTypes 01DamageTypes 02

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.

DamageTypes 03

For example, you could decide each damage received to the head will be multiplied by 2:

DamageTypes 04


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

DamageTypes 05

Functions

DamageTypes 06


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.

DamageTypes 12



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.

DamageTypes 14

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.

DamageTypes 07

Make sure "DamageCauser" pin is filled with the bullet actor reference (see below for more info on limitations)

DamageTypes 10

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.

DamageTypes 08


Variables with suffix "L_" are local variables!

BlueprintUE.com Link to "GetNearestBoneToActor"



Firing the physical bullet to our character will now apply damage to correct bone.

DamageTypes 09

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 DamageTypes 11




Edited by: Klian

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.