Disable all instances of a component

I am trying to disable mouse look on ‘q’.

Here is my code as is.

#pragma strict
public var paused = false;;

//This script is on the main camera
function Start () {


function Update () {
		paused = !paused;
		//Toggle caputred cursor
		Screen.lockCursor = false;
		//disable mouselook
		//This needs to be changed to disable the FPS controllers script
		GetComponent(MouseLook).enabled = false;
		//This should kill the cameras script
		Camera.mainCamera.GetComponent(MouseLook).enabled = false;
		Time.timeScale = 0;
		Screen.lockCursor = true;
		GetComponent(MouseLook).enabled  = true;
		Camera.mainCamera.GetComponent(MouseLook).enabled = true;
		Time.timeScale = 1;



The issue is that it only disables it on one axis (e.g cameras axis or players axis ).

So how do i disable both scripts and re-enable both scripts on the generic First Person Controller?


I’m not sure why you would want or need 2 MouseLooks on one object, but you could use GetComponents(MouseLook) to get a list of them, then use a ‘for’ loop to set each’s enables as needed.

Mouse Look and Character Motor off but i can still see :( help plox? - Questions & Answers - Unity Discussions I think haxard’s answer is what you need.