LSBUGPG / UnityLibrary

A library of useful Unity components and test scenes
GNU General Public License v3.0
0 stars 0 forks source link

Pause menu #22

Closed notleeandrew closed 8 years ago

notleeandrew commented 8 years ago

When I press "P" I want time to stop and all inputs to be rendered moot so that nothing will happen

charliedadams commented 8 years ago
void Update () {
    if (Input.GetKeyDown(KeyCode.P)) {
        if (Time.timeScale == 1) {
            Time.timeScale = 0;
        } else {
            Time.timeScale = 1;
        }
charliedadams commented 8 years ago

this is how i did a pause function to the game

gamingdevotee commented 8 years ago

I tried this out and it seems to work though you may want to clarify what to put this code on for future reference (an empty gameObject).

My two stars

  1. The code is simple
  2. The code is neat

My wish If you could show how to work the UI after pausing the game e.g.

pause game -> opens menu -> can select to continue player, restart at last checkpoint etc.

This would help out a lot should anybody want to make a more elaborate pause menu.