void OnTriggerStay2D(Collider2D col) { if (continuousDamage && ti[0] + 1 / hitRate > Time.time && col.gameObject != null) { GameObject obj = col.gameObject; if (col != null && obj != parentObj && !obj.CompareTag(tag) && col.gameObject.tag != parentObj.tag) { if (obj.GetComponent <HealthSystem>() != null) { HealthSystem hp = obj.GetComponent <HealthSystem>(); hp.DoDamage(dmg); ti[0] = Time.time; } } } }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject != null) { GameObject obj = col.gameObject; if (col != null && col.gameObject != parentObj && !obj.CompareTag(tag) && col.gameObject.tag != parentObj.tag) { if (obj.GetComponent <HealthSystem>() != null) { HealthSystem hp = obj.GetComponent <HealthSystem>(); hp.DoDamage(dmg); if (destroyOnCollide) { Destroy(gameObject, 0.1f); } //De-attach children with timed destruction } } } }
public void OnTriggerEnter(Collider otherCollider) { GameObject hitObject = otherCollider.gameObject; if (behaviour != null) { if (behaviour.GetIsDamaging() == true) { if (hitObject.GetComponent <PlayerInputHandler>() != null) { HealthSystem playerHealth = hitObject.GetComponent <HealthSystem>(); playerHealth.DoDamage(behaviour.attackDamage); } } } else { behaviour = GetComponentInParent <ZombieBehaviour>(); } }