© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
C. HardmanGame Programming with Unity and C#https://doi.org/10.1007/978-1-4842-9720-9_23

23. In-Game Pause Menu

Casey Hardman1  
(1)
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 ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.