Starting the game
At the moment, our gameplay starts automatically after pressing the Play button in Unity. This was convenient for testing running and jumping. If you look into the Start
method in GameManager
, you will notice we are calling the start game there. Let's remove that line and keep the Start
method empty for now.
Further in the development of this game, we will have a nice Graphic User Interface (GUI) to control the game states by pressing buttons like Start Game, Restart, and so on. For now, we should focus on functionality only and leave the GUI for later. However, we do need an easy way to call the events at runtime. Why not use the keyboard for now? You probably remember using Input.GetKeyDown
. If you don't remember much, dive into Unity Scripting Reference again and search for Input.GetKeyDown
.
Let's say when each time user presses S on the keyboard, we will fire up the StartGame
method on GameManager
. Before we start adding code, we need to make sure that currentGameState...