Quit! Making an escape clause for your player in full screen mode.

One last thing I’m going to add to my game is a way for the player to quit (although I’m sure they won’t!). When you build your game you may opt to have it start in full screen, which is the way all games should be played. The problem is, once in there there is no way out. You have to do the dreaded Ctrl-Alt-Del.

So I made a Game Manager which controls the state of the game. This is a perfect place for this. We want to make it so when the player presses the escape key we want the game to quit.

Now a word of warning here, you cannot test this in the Unity Editor. It’s one of the few things you can’t test, but it’s true. You have to do a build to see if it works.

So the code is pretty straight forward. Inside the GameManager we created we are just going to check for input as follows:

That’s it, simple.

Now that we have this my game is very close to completion. I will be adding the following features to it in the upcoming articles.

  • Thrusters — When player presses shift key the ship will move faster.
  • Making the shield a 3 hit object and change colour or size every hit.
  • Give the Player a warning when player is out of ammo.
  • Create secondary fire for player with new type of laser or missile.
  • Give thrusters a UI element for cool down when used too much.
  • When Player is hit shake camera.

So a lot to do! I’ll keep you posted with articles on the above additions as I move along.

Happy Clicking!

With Unity all can be accomplished!