The point is to disable/enable the script on the press of a button.
Here’s the script that’s supposed to disable the MouseLook:
var locked : boolean = true;
function cursorLock() {
Screen.lockCursor = true;
Screen.lockCursor = false;
}
function Update() {
if (locked == true) {
cursorLock();
}
if (Input.GetKeyDown("i")) {
locked = false;
//disable MouseLook
}
if (Input.GetKeyDown("o")) {
locked = true;
}
}
I’ve done some google searches and tried some of these methods:
GetComponent(MouseLook).enabled = false;
GetComponent(MouseLook).enabled = !GetComponent(MouseLook).enabled;
var mouseLook : MouseLook;
mouseLook = !mouseLook.enabled;
None of them seem to work.
Here’s the error message I get most often:
“MouseLook” is not a member of ‘function(System.Type):UnityEngine.Component’"
It may be because MouseLook is not recognized as a Component(?), but I don’t know.
Any help is appreciated!
- Predator