private void OnTriggerEnter2D(Collider2D collision) { Attacker attacker = collision.gameObject.GetComponent <Attacker>(); health healh = collision.gameObject.GetComponent <health>(); if (attacker && healh) { healh.DealDamage(damage); Destroy(gameObject); } }
// Called from the animator at the time of the actual blow void StrikeCurrentTarget(float damage) { if (currentTarget) { //Debug.Log(name + " dealt" + damage + " damage"); health hp = currentTarget.GetComponent <health>(); if (hp) { hp.DealDamage(damage); } } }
public void StrikeCurrentTarget(float damage) { if (!currentTarget) { return; } health Health = currentTarget.GetComponent <health>(); if (Health) { Health.DealDamage(damage); } }