//private void OnTriggerEnter(Collider other)
    //{
    //    if (other.transform.tag == "zombie")
    //    {
    //        Vector3 dir = other.transform.position - transform.position;
    //        //Vector3 knockBackPos = other.transform.position * (-dir.normalized * knockBack);
    //        Vector3 knockBackPos = other.transform.position + (dir.normalized * knockBack);
    //        knockBackPos.y = 1;
    //        other.transform.position = knockBackPos;
    //        Explosion();
    //    }
    //}

    void Damage(Transform zombie, float damageAmount)
    {
        zombie z = zombie.GetComponent <zombie>();

        if (z != null)
        {
            z.TakeDamage(damageAmount);
        }
    }
Exemplo n.º 2
0
 public void Explode()
 {
     ExplosionSound.Play();
     Collider2D[] objectsInRange = Physics2D.OverlapBoxAll(transform.position, new Vector2(radius, radius), 0);
     foreach (Collider2D col in objectsInRange)
     {
         zombie script = col.GetComponent <zombie>();
         if (script)
         {
             script.TakeDamage(damage);
         }
     }
 }