private void OnTriggerEnter2D(Collider2D col) { //Debug.Log(col); //Debug.Log(col.gameObject.name); if (!gameObject.CompareTag("Bullet") || col.gameObject.CompareTag("Bullet") || col.gameObject.CompareTag("Player") || col.gameObject.CompareTag("EniBullet") || col.gameObject.CompareTag("healthPod")) { return; } if (col.gameObject.CompareTag("destrutable_wall")) { breakable_Wall = col.gameObject.GetComponent <breakable_wall>(); breakable_Wall.health -= dmg; } if (gameObject.CompareTag("Bullet") && col.gameObject.CompareTag("Eni") || col.gameObject.CompareTag("Zombie")) { var eni = col.gameObject.GetComponent <eni.eni>(); // decrease my health by the bullet damage dmg = bullet1.dmg * (int)bulletmultiplier; eni.health -= dmg; } Destroy(gameObject); }
void OnTriggerEnter2D(Collider2D col) { //Debug.Log(col); //Debug.Log(col.gameObject.name); if (gameObject.tag == "Bullet" && col.gameObject.tag != "Bullet" && col.gameObject.tag != "Player" && col.gameObject.tag != "EniBullet" && col.gameObject.tag != "healthPod") { if (col.gameObject.tag == "destrutable_wall") { breakable_Wall = col.gameObject.GetComponent <breakable_wall>(); breakable_Wall.health -= dmg; } if (gameObject.tag == "Bullet" && col.gameObject.tag == "Eni" || col.gameObject.tag == "Zombie") { eni.eni Eni = col.gameObject.GetComponent <eni.eni>(); // decrese my health by the bullet damage Eni.health -= dmg; } //Destroy(gameObject); } }