2D Galaxy Shooter — How to Quit the Game using ESC

Marcus Cohee
Sep 2, 2021

Hello all!

Today, I will go over how to quit your game by using the Escape key! This is pretty simple but will be needed for test builds.

Code for Quitting your Game

  1. Open the GameManager script you made before, then add this if statement to the Update() method!

That was it… See pretty simple! If you hit the Escape key, quit application.

This is useful so we don’t have to have our end users struggle to close a program. I don’t want my end users mad at me!

  • Note: This feature does not work in the Unity editor, you will need to test it in a build of your game!

This was how to quit a game! Next, I will start by making my enemies fire lasers down at me!

Thank you for your time!

--

--

Marcus Cohee

I am starting Unity and learning the ropes as I go! Let’s take this journey together!