Search Unity

Need help ASAP

Discussion in 'Scripting' started by MyCatFishSteve, Jan 28, 2013.

  1. MyCatFishSteve

    MyCatFishSteve

    Joined:
    Jan 13, 2013
    Posts:
    55
    I need help with my code to pause the game this is my code

    function Update () {
    if (Input.GetKeyDown("escape"));
    {
    Application.LoadLevel : ("main_menu");
    }

    }

    My error - Assets/Custom Scripts/Pause.js(4,59): BCE0044: expecting :, found ';'.
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Code (csharp):
    1.  
    2. function Update () {
    3. if (Input.GetKeyDown("escape")
    4. {
    5. Application.LoadLevel("main_menu");
    6. }
    7.  
    8. }
    9.  

    But this will not pause your game. It will load level "main_menu". To pause you will want to you use Time.timeScale = 0;
     
  3. MyCatFishSteve

    MyCatFishSteve

    Joined:
    Jan 13, 2013
    Posts:
    55
    umm you forgot the ) at line 2 to end it but thanks anyways (btw i wanted to use the application thing to get back to the main menu)
     
  4. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    Warning: Using Application.LoadLevel() pretty much destroys your current scene. Are you sure you want to take that step to pause your game?
     
  5. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    my bad, I was taking out your ";" on line 2. And you need to learn better english. See your post 1.

     
    Last edited: Jan 28, 2013