Use this when you want to be able to attack non-humanoid objects , destroy crates, attack a dummy or want to create your own health script.

Step 1:

In your MonoBehaviour script add IDamageable after MonoBehaviour

public class YourDamageScript: MonoBehaviour,IDamageable

Step 2:

Add the following variables and methods in your script

//Variables
int AttackId{get;set;}

//Method
void TakeDamage(MeleeCombatSystem meleeCombatSystem,DamageType damageType,Attack attack);

void TakeDamage(MeleeCombatSystem meleeCombatSystem);

void DepleteHealth(float amount);

Step 3:

AttackId (int) - this is an internal variable, do not modify.

void TakeDamage()

Check IDamageable for more information about the variables.

void DepleteHealth

amount (float) - use this value to reduce health.