Well done so far. You have added basic functionality like jumping, physics, and running to the PlayerController
object. We are definitely going in the right direction here. The next important step is writing a neat GameManager
class to help us control the game events like:
StartGame
GameOver
Restart
For basic games like Jake on the mysterious planet, it is a good practice to have one instance of the GameManager
running and controlling all main events in the game. The gameplay
loop is simply a journey from the gameplay start to the gameplay phase and the game over phase. Time to write some code!
Let's create a new C# script and call it GameManager
, and write the following code:
As you can see, nothing is very complicated. We wrote very simple methods to help us control the main game events. This script does nothing yet; however, please add it to the Unity Scene. Create a new game object call it GameManager
, and add the GameManager
component to it. We will use it in the future...