Set up parameters in your damage function.
like this for example:
public float CurrentHealth;
public float DamageThreshold;
public float DamageResistance;
public void takeDamage(float Damage, float AP){
CurrentHealth -= (Damage - Mathf.Max(DamageThreshold - AP,0)) * (1-DamageResistance);
}
so when you want to apply damage you'd have script on your projectile for example that would find the takeDamage function in the Health script on the target.
public float Damage;
public float AP;
/* With a raycast hit for example */
health = hit.transform.gameObject.GetComponent();
if(health != null){health.takeDamage(Damage, AP);}
I'm using armor penetration and damage resistance, but you could take those out or add in other types of resistance, damage or effects.
↧