void OnTriggerEnter2D(Collider2D other) // If bullet hits an something, destroy it { if (other.gameObject.tag == "Enemy") // hit enemy, destroy enemy if the object has an enemy tag { // Debugging //Debug.LogError("Bullet hit: " + other.gameObject.name); gm.gameScore += other.gameObject.GetComponent <EnemyCS>().value; // add enemy value to the score in the game manager Destroy(other.gameObject); // destroy the enemy AudioSource.PlayClipAtPoint(impactSound, transform.position, 0.5f); // play impact sound sound gm.CheckLevel(); // see what level the player is on DestroyBullet(); } else if (other.gameObject.tag == "Saucer") // hit the saucer { //Debug.LogError("Bullet hit: " + other.gameObject.name); gm.gameScore += other.gameObject.GetComponent <SaucerCS>().value; Destroy(other.gameObject); AudioSource.PlayClipAtPoint(impactSound, transform.position, 0.5f); DestroyBullet(); gm.saucerMade = false; // saucer is destroyed so set to false } else if (other.gameObject.tag == "Shelter") // hit the shelter { Destroy(other.gameObject); DestroyBullet(); } }