x


How can I pause the "Mouse Look" script when I pause my game?

Im trying to create a 'pause-game' button, so far I've managed to pause the game and sound. But Im having trouble pausing the camera (Mouse Look Script), is there something I have not added to the script? Appreciate any help.

var pausedGUI : GUIText; pausedGUI.enabled = false;

static var pauseVisible : boolean; private var player : GameObject; private var cam : GameObject;

function Start() {

 // initially hide the pause menu
 pauseVisible = false;
 player = GameObject.Find("First Person Controller");
 cam = GameObject.Find("Main Camera"); 

}

function Update () { if(Input.GetKeyUp("p")){ if(paused == true){ paused = false; } else { paused = true; }

     if(paused == true){
         Time.timeScale = 0.0;
         pausedGUI.enabled = true;
     } else {
         Time.timeScale = 1.0;
         pausedGUI.enabled = false;
     }

     if(paused == true){
         AudioListener.pause = true;
     } else {
         AudioListener.pause = false;        
     }

     if(paused == true){
         GetComponent("MouseLook").enabled = true;
     } else {
         GetComponent("MouseLook").enabled = false;
     }  
 }

}

more ▼

asked Apr 23 '11 at 09:54 PM

Ben 39 gravatar image

Ben 39
5 11 12 16

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I heavily modified the pause menu script found on the Unity wiki for my own game. I pasted below a link to the code I used (in JavaScript).

I also posted this on the most popular pause game question thread, but I doubt anyone will ever consider looking at it since the question already has 11 answers. Look at the UnPauseGame and PauseGame functions for how to solve the MouseLook problem, but if you want you can just use the whole script.

Link to the modified Pause Menu script

more ▼

answered May 10 '11 at 03:36 AM

Justin 3 gravatar image

Justin 3
27 3

Thank you so much...the problem is finally solved. Definately a great script for helping first time game devs.

May 10 '11 at 04:21 PM Ben 39

I'm glad I could help.

May 14 '11 at 07:49 AM Justin 3
(comments are locked)
10|3000 characters needed characters left

Pleese publish full text script

more ▼

answered Aug 29 '12 at 12:45 AM

neduser gravatar image

neduser
-14

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3416
x268
x164

asked: Apr 23 '11 at 09:54 PM

Seen: 2085 times

Last Updated: Aug 29 '12 at 12:45 AM