© Casey Hardman  2020
C. HardmanGame Programming with Unity and C#https://doi.org/10.1007/978-1-4842-5656-5_23

23. In-Game Pause Menu

Casey Hardman1 
West Palm Beach, FL, USA

Now we need some means of getting back to the main menu from within the game. We’ll add this in the form of a menu that the player can open by pressing the Esc key. It also wouldn’t hurt for that menu to pause the game while it’s up and unpause when we close it.

Freezing Time

Everything in our game is based on time. We use Time.deltaTime to measure the distance something will move in a frame. We use Time.time to measure how long it’s been since something happened. We use Invokes to time the player’s respawning and the Wanderer retargeting.

This can all be manipulated with the ...

Get Game Programming with Unity and C#: A Complete Beginner’s Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.