I’m writing a script to disable moving the camera and moving the character when certain variables are true/false. It works fine, except for the script attached to the camera (I have the same problem in a similar script that handles pausing).

Here’s my code:

var inUse : boolean = false;
var charControllerDisabled : boolean = false;

private var FirstPersonController : GameObject;

function Start() {

FirstPersonController = GameObject.Find("FirstPersonController");

}

function Update () {

if(inUse && !charControllerDisabled){
	
		
	FirstPersonController.GetComponent("CharacterController").enabled = false;
	FirstPersonController.GetComponent("MouseLook").enabled = false;	
	FirstPersonController.GetComponent("CharacterMotor").enabled = false;
	FirstPersonController.GetComponent("FPSInputController").enabled = false;
	
	FirstPersonController.GetComponentInChildren(MouseLook).enabled = false;
	
		



    }

}

I suspect the problem is that the camera is not a GameObject but a Camera. However, I’ve tried referencing the Camera directly, and that didn’t work either. Any help would be appreciated.

Here is what I tried, worked for me :slight_smile:

Camera.mainCamera.GetComponent("MouseLook").enabled = false;

Clunk47@Gmail.com