Pause Menu

I am complete with my game. However, how do you create a pause menu. Here is my script:
var paused : boolean = false;

function Update ()
{

if(Input.GetButtonUp(“Fire3”)){
if(!paused){
Time.timeScale = 0;
paused = true;
}

else
{
paused = false;
Time.timeScale = 1;
}
}
}

Can you post your code using ‘code’ tags and with correct indentation? (I know it’s a short excerpt, but the logic will be easier to follow if it’s formatted correctly.)

function Update ()
{

if(Input.GetButtonUp(“Fire3”))
{
if(!paused)
{
Time.timeScale = 0;
paused = true;
}

else
{
paused = false;
Time.timeScale = 1;
}
}
}

facepalm

I am new to Unity, what is facepalm

The code you posted should correctly pause the game. If you want a menu to appear, as well, the Unity GUI class will be very helpful. You can find the GUI class in the script reference >here<.

All your GUI commands have to be called from OnGUI(). However, since you already have a paused boolean variable, you could use that to turn on and off your menu. Something like this:

var windowWidth : int = 150;
var windowHeight : int = 200;
var windowRect : Rect = Rect( Screen.width/2 - windowWidth/2, Screen.height/2 - windowHeight/2, windowWidth, windowHeight );

function OnGUI()
{
   if( paused )
   {
      // 3rd parameter is the function where you will place all your GUI controls that should be in the window
      GUI.Window( 0, windowRect, PausedWindow, "Paused" );
   }
}

function PausedWindow( )
{
   //all your buttons or other gui components for your window go here, for example:
   GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" )
   {
       Application.LoadLevel("MainMenu");
   }
}

If you add this code to your existing script, anytime your ‘paused’ variable becomes true, the window will appear, and you’d have a button that would load a level named “MainMenu.” If you just want some text that says “Paused” instead of a menu, you could have something like:

function OnGUI()
{
   if( paused )
   {
       GUI.Label( Rect( 50, 50, 150, 30), "PAUSED" );
   }
}

However you decide to build your pause menu, I’d recommend using your ‘paused’ variable to turn on and off GUI components called in OnGUI(). I hope this is along the lines you were asking for…I do believe your code pauses the game fine, and that you just want a menu to appear when the game is paused.

It’s not a Unity thing. Anyway, what I said earlier was:

But you did neither of those things. You got the help you needed anyway in this case, but in the future, please use ‘code’ tags and proper formatting, as it’ll make your posts easier to read. (If you’re not sure what I mean, feel free to ask.)

Thanks Keryu. I am in GA too. This is my email address, genovis@att.net. I am near downtown. Thanks. Also, I would like for you to check out my game.

I do not know what you mean and thanks. How do you use code tags?

Thanks Azul.