Search Unity

Disable MouseSensitivity When Paused JS

Discussion in 'Scripting' started by Carlos2295, Apr 27, 2015.

  1. Carlos2295

    Carlos2295

    Joined:
    Apr 13, 2015
    Posts:
    6
    When the game is paused, I want to disable the mouse sensitivity so that the player cannot move the camera. Instead of actually disabling the MouseLook script, I thought this would be an easier workaround. Here's the script for the pause menu I have so far.
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var Paused : boolean = false;
    4. var PauseButton : UnityEngine.UI.Text;
    5. var PauseButton2 : UnityEngine.UI.Text;
    6.  
    7. function Update ()
    8.  
    9. {
    10.  
    11.     if (Input.GetKeyDown("escape") && Paused == false)
    12.  
    13.     {
    14.         Paused = true;
    15.         Time.timeScale = 0;
    16.         PauseButton.text = "Paused";
    17.         PauseButton2.text = "Press Q to Return to Main Menu";
    18.         Cursor.visible = true;
    19.     }
    20.  
    21.     else if (Input.GetKeyDown("escape") && Paused == true)
    22.  
    23.     {
    24.         Paused = false;
    25.         Time.timeScale = 1;
    26.         PauseButton.text = "";
    27.         PauseButton2.text = "";
    28.         Cursor.visible = false;
    29.     }
    30.  
    31.     if (Input.GetKeyDown("q") && Paused == true)
    32.  
    33.     {
    34.         Paused = false;
    35.         Time.timeScale = 1;
    36.         PauseButton.text = "";
    37.         PauseButton2.text = "";
    38.         Application.LoadLevel(0);
    39.     }
    40.  
    41. }