GAME OVER - ON COLLISION ENTER ()
As opposed to OnTriggerEnter(), OnCollisionEnter() method can be called when two rigidbody collides. We cannot set our asteroids Collider.isTrigger active. Doing so will pass the laser through the asteroid. In this case, I wanted to declare the life of space ship to be 3. Every time an asteroid collides the spaceship, its life is reduced by 1. When life of spaceship reaches 0, it gets destroyed and Game is Over.
To accomplish this, I declared a new variable of type int playerLife = 3 in PlayerController.cs script. Also a boolean "isGameOver" was declared and set to False.
OnCollisionEnter() method was then used. A "nested-if" statements were used to check different conditions:
Condition 1: Is the object that the player is colliding with tagged as "Asteroid" and is the game over set to false?
If so, the destroy the Asteroid and reduce player life by 1
Nested Condition 1: if player life reaches 0;
Set isGameOver to True
Display Game Over is Console! (This is to test if our Game Over script works, I will be working on stopping the game and instantiation of objects once the game is over. In further sections, UI elements will also be included to show game's status)
... PROGRESS SO FAR ...