void OnTriggerEnter2D(CircleCollider2D otherCollider) { // Is this a shot? bombchase shot = otherCollider.gameObject.GetComponent <bombchase>(); if (shot != null) { // Avoid friendly fire if (shot.isEnemyBomb != isEnemy) { } } ShotScript blast = otherCollider.gameObject.GetComponent <ShotScript>(); if (blast != null) { // Avoid friendly fire if (blast.isEnemyShot != isEnemy) { PlayBurst(); Damage(blast.damage); // Destroy the shot Destroy(blast.gameObject); } } }
void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? EnemyShotScript shot = otherCollider.gameObject.GetComponent <EnemyShotScript>(); if (shot != null) { // Avoid friendly fire if (shot.isEnemyShot != isEnemy) { Damage(shot.damage); hpbar.value = (hp); // Destroy the shot PlayExplosion(); Destroy(shot.gameObject); } } bombchase bomb = otherCollider.gameObject.GetComponent <bombchase> (); if (bomb != null) { if (bomb.isEnemyBomb != isEnemy) { Damage(bomb.damage); hpbar.value = (hp); } } addhealth health = otherCollider.gameObject.GetComponent <addhealth> (); if (health != null) { if (health.isHealth != isEnemy) { Damage(health.damage); hpbar.value = (hp); Destroy(health.gameObject); } } }