void OnCollisionEnter2D(Collision2D hit) { if (hit.gameObject.tag != "Player") { if (hit.collider.isTrigger == false) { //Debug.Log ("We hit " + other.name + " and did Test damage."); if(transform.gameObject.tag != "Player"){ if (hit.collider.tag == "Enemy") { soldier = hit.collider.gameObject.GetComponent<Soldier>(); mib = hit.collider.gameObject.GetComponent<MIB>(); dozer = hit.collider.gameObject.GetComponent<Bulldozer>(); if(soldier != null) { Debug.Log("hit"); soldier.DecreaseHealth(Damage); } if(mib != null) { Debug.Log("hit"); mib.DecreaseHealth(Damage); } if(dozer != null) { Debug.Log("hit"); dozer.DecreaseHealth(Damage); } } } } } /* else if (other.tag != "Player") { Destroy (gameObject); Debug.Log ("You were hit"); playerGameObj = GameObject.Find("Player"); player = playerGameObj.GetComponent<Player>(); player.DecreaseHealth(Damage); } */ }