private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.CompareTag(TargetTag)) { if (Time.time >= nextShock) { HealthKeeper Hk = collision.GetComponent <HealthKeeper>(); if (Hk != null) { nextShock = Time.time + shockCooldown; anim.SetBool("active", true); Hk.Hurt(damage); } else { anim.SetBool("active", false); } } else { anim.SetBool("active", false); } } else { anim.SetBool("active", false); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag(TargetTag)) { HealthKeeper hk = collision.gameObject.GetComponent <HealthKeeper>(); if (hk) { hk.Hurt(damage); } } if (effect) { Instantiate(effect, transform.position, transform.rotation); } Destroy(gameObject); }