// Start is called before the first frame update void Start() { crash = this; titleText.enabled = true; gameOverText.enabled = false; scoreText.enabled = false; startGameButton.SetActive(true); }
// OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider private void OnCollisionEnter(Collision collision) { //If enemies hit player ship then destroy the player ship if (collision.gameObject.GetComponent <Player>() != null) //if player ship exists { CrashteroidsMaster.GameOver(); Destroy(gameObject); } }
// OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider private void OnCollisionEnter(Collision collision) { if (collision.gameObject.TryGetComponent <Enemies>(out Enemies aliens)) { CrashteroidsMaster.BadShipDestroyed(); //Update score Destroy(gameObject); //Destroy lazer spawner.enemyShips.Remove(collision.gameObject); //Remove enemy ship from list Destroy(collision.gameObject); //Destroy enemy ship } }
public void SetUp() { GameObject gameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/Game")); crashteroids = gameObject.GetComponent <CrashteroidsMaster>(); }