Can't disable MouseLook or CharController

Hi guys

So I have this script where when the player gets in the Trigger the MainCamera rotates. Of course I want to disable MouseLook and CharacterController so there are no turned around moving. However for some mysterious reason neither of the above mentioned omponents want to get disabled and I have no idea why. I was searching through forums, but didn’t find any answer yet.

Thanks in advance :slight_smile:

private var InRange : boolean;
private var mainCam : GameObject;
private var finishedTurning : boolean;
private var startTurning : boolean;
private var player : GameObject;

var hideCam : Camera;
var smooth : float;

function Awake()
{
	mainCam = GameObject.FindGameObjectWithTag("MainCamera");
	player = GameObject.FindGameObjectWithTag("Player");
}

function OnTriggerEnter (theCollider : Collider)
{
	if (theCollider.tag == "Player")
	{
		InRange = true;
	}
}

function OnTriggerExit()
{
	InRange = false;
	finishedTurning = false;
	startTurning = false;
}

function Update()
{
	if(startTurning  InRange  !finishedTurning)
	{
		mainCam.transform.rotation = Quaternion.Lerp(mainCam.transform.rotation, hideCam.transform.rotation,Time.deltaTime*smooth);
	}
	
	if( Mathf.Abs(mainCam.transform.rotation.y-hideCam.transform.rotation.y) < 0.01)
	{
		finishedTurning = true;
	}
	
	if(Input.GetKeyDown(KeyCode.E)  InRange)
	{
		player.GetComponent(CharacterController).enabled = false;
		player.GetComponent(MouseLook).enabled = false;
		mainCam.GetComponent(MouseLook).enabled = false;
		startTurning = true;
	}
}

If you don’t mind modifying the mouse look script, just put a boolean variable in it to disable the input line.

Okay, but what would I do with the Char. Controller?

Basically the same thing. Find the input line(s) and add a boolean for pause or whatever.

But the Char. Controller is like a collider isn’t it? How could I edit it?

I don’t think you want to disable the collider do you? I thought you just meant the script that controls it like rotate, move, etc. Those are scripts that are attached to the controller. Just click on it and you should see them.

Okay, sorry I misunderstood you, since I’m not using that script but another controller script. Anyway it works now, so thanks for the help :slight_smile: