private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "bullet") { TakeDamage(); } AlienBullet b = collision.transform.GetComponent <AlienBullet>(); if (b != null) { b.Death(); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "bullet") { TakeDamage(); } AlienBullet b = other.transform.GetComponent <AlienBullet>(); if (b != null) { b.Death(); } }
public void DestroyShield() { foreach (GameObject obj in caughtObject) { AlienBullet a = obj.GetComponent <AlienBullet>(); if (a != null) { a.Death(); } else { Destroy(obj); } } Destroy(this.gameObject); }