void OnTriggerEnter(Collider other) { if (other.tag == "Boundary") { return; } Instantiate(explosion, transform.position, transform.rotation); if (other.tag == "Player") { if (currentLives == 0) { ; } { Instantiate(playerExplosion, other.transform.position, other.transform.rotation); GameController.GameOver(); } GameController.RemoveLife(); currentLives -= 1; /*if( currentLives == 0 ) * { * //Destroy (other.gameObject); * GameController.GameOver(); * }*/ } GameController.AddScore(scoreValue); Destroy(other.gameObject); Destroy(gameObject); }
void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Player")) { // Instantiate(playerExplosion, other.transform.position, other.transform.rotation); GC.GameOver(); } Destroy(other.gameObject); Destroy(gameObject); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "enemy01") { gameController.GameOver(); } if (collision.gameObject.tag == "enemy02") { gameController.GameOver(); } if (collision.gameObject.tag == "enemy03") { gameController.GameOver(); } if (collision.gameObject.tag == "enemy04") { gameController.GameOver(); } if (collision.gameObject.tag == "enemy05") { gameController.GameOver(); } }
void OnTriggerEnter(Collider other) { if (other.tag == "Boundary") { return; } Instantiate(explosion, transform.position, transform.rotation); if (other.tag == "Player") { Instantiate(playerExplosion, other.transform.position, other.transform.rotation); gameController.GameOver(); } gameController.AddScore(scoreValue); Destroy(other.gameObject); Destroy(gameObject); }
void OnTriggerEnter(Collider other) { if (other.tag == "Boundary") //will ignore the boundary gameObject { return; } Instantiate(explosion, transform.position, transform.rotation); if (other.tag == "Player") { Instantiate(playerExplosion, other.transform.position, other.transform.rotation); gameController.GameOver(); } gameController.AddScore(scoreValue); Destroy(other.gameObject); //destroy any object shot by player Destroy(gameObject); //destroy player if make contact with asteroid or enemy }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Boundary") || other.CompareTag("Enemy") || other.CompareTag("Boss")) { return; } { if (explosion != null) { Instantiate(explosion, transform.position, transform.rotation); } gamecontroller.addScore(score_value); if (other.CompareTag("Player")) { Instantiate(Player_explosion, other.transform.position, other.transform.rotation); gamecontroller.GameOver(); gamecontroller.RestartButtonActivate(); } Destroy(other.gameObject); Destroy(gameObject); } }