So here is my problem, i hava GUI menu that when i toggle it when i press Escape i want the mouse and everything to freeze. I’ve made a script that disables the whole script using the .enable = false. But the camera still rotates along the X axis, while the Y axis is frozen. And the “check box” next to the script in Camera is unchecked…
here is my code:
var mouseSource : GameObject;
function Update() {
var mouseLook = mouseSource.GetComponent("MouseLook");
if (GUIGroup.menuOn == true) {
mouseLook.enabled = false;
Time.timeScale = 0;
return;
}
else if (GUIGroup.menuOn == false){
mouseLook.enabled = true;
Time.timeScale = 1;
return;
}
}
Maybe its just me, but imo the camera shouldnt be able to move if the script is disabled.
Ok I solved it, aparently the FPS controller from the Standard Assets have one MouseLook in the FPS Controller and one on the Main Camera.
New problem:
I get an error: Object reference not set to an instance of an object.
here is the code:
var target : GameObject;
var mouseLook = target.GetComponent("MouseLook");
function Update() {
if (GUIGroup.menuOn == true) {
mouseLook.enabled = false;
Time.timeScale = 0;
return;
}
else if (GUIGroup.menuOn == false){
mouseLook.enabled = true;
Time.timeScale = 1;
return;
}
}
i also has a same problem, but it already solved now,
here is my code :
mouseLook = this.GetComponent("MouseLook");
mouseLook.enabled=true;
you can put it in the same gameObject, so the script only need to look for the component in the same object.
- sory for my bad english [wovie] :lol: