Turning off Mouse look script not working

Hi,

I’m using a script that disables the mouse look script on the first person controller. I used it on a previous project in Unity 3.4 worked fine.
I’m now using 4.0 and the script doesnt work. I just get an error that says (NullRefrenceException: Object refrence not set to an instance of an object.)

this is the script I’m using

public static var SpaceDown1 : int = 0;

function Update ()
{
if (Input.GetKeyDown (“space”) SpaceDown1 == 0)
{
Debug.Log(“Mouse Look Off”);

transform.GetComponent(“MouseLook”).enabled = true;

SpaceDown1 = 1;
}
else if (Input.GetKeyDown (“space”) SpaceDown1 == 1)
{
Debug.Log(“Mouse Look On”);

transform.GetComponent(“MouseLook”).enabled = false;

SpaceDown1 = 0;
}
}

Any help would be great. Thanks!

try using gameObject instead of “transform”
perheaps it solves, let me know if it works

Hi Rafael,

I turns out I had to move my script outside of the standards assets folder for it to work.

Thanks for your help!