- Home /
Toggle MouseLook On/Off Problem
I have a problem with the MouseLook script. When i press Esc the pause menu comes up but i cant disable the FPS-MouseLook. I have the JS version of MouseLook. I set the script on Main Camera and FPS Controller. But it says:
.
NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name) UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name) MouseDisable.Update () (at Assets/Scripts/MouseDisable.js:6)
.
.
This is the script i wrote, please help?
function Update ()
{
if(Input.GetKeyDown("escape"))
{
GetComponent("MouseLook").enabled = !GetComponent("MouseLook").enabled;
}
}
Answer by DaveA · Jun 12, 2013 at 07:13 PM
Make sure this script is on the exact same object as MouseLook. Otherwise, you may want to GameObject.Find and/or use GetComponentInChildren
Your answer
Follow this Question
Related Questions
GetComponent NullReferenceException 1 Answer
Why my c# script doesn't work? 1 Answer
Toggle camera sensitivity 1 Answer
invert mouse Y-axis hotkey & icon de facto standard 0 Answers
UI Toggle Component Broken? 0 Answers