void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "bonusShip") { Destroy(col.gameObject); ship.destroyBonusshipPlay(); } }
//Destroy player if obstacle hits player void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Player") { crashSound.Play(); FindObjectOfType <GameManager>().EndGame(); Destroy(col.gameObject); } if (col.gameObject.tag == "bonusShip") { Destroy(col.gameObject); ship = GameObject.FindWithTag("Player").GetComponent <spaceship>(); ship.destroyBonusshipPlay(); } }