I never entirely understood this error, I just know it’s bloody irritating, but here’s the code it’s complaining about:
var graphicsComponent: Transform;
var cameraComponent: Transform;
function Start () {
if(graphicsComponent.networkView.isMine){
GetComponent("FPSInputController").enabled = true;
GetComponent("CharacterMotor").enabled = true;
GetComponent("MouseLook").enabled = true;
cameraComponent.camera.enabled = true;
cameraComponent.GetComponent("MouseLook").enabled = true;
cameraComponent.AudioListener.enabled = true;
}
}
function OnDisconnectedFromServer() {
DestroyObject(gameObject);
}
And the full error report:
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.SetProperty (System.Object target, System.String name, System.Object value) OwnerControl.Start () (at Assets/Standard Assets/Scripts/Networking Scripts/OwnerControl.js:11)
Anyone know what I’m doing wrong?
Yeah, here is is.
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.SetProperty (System.Object target, System.String name, System.Object value)
OwnerControl.Start () (at Assets/Standard Assets/Scripts/Networking Scripts/OwnerControl.js:11)
I believe that almost every line of your script could be wrong:
Line 5 - graphicsComponent
could be null if it is not set in the inspector yada yada
Line 6 - GetComponent
could return null if no FPSInputController
is added to the GO yada yada.
Line 7 - GetComponent
could return null if no CharacterMotor
is added to the GO yada yada.
Line 8 - GetComponent
could return null if no MouseLook
is added to the GO yada yada.
Line 9 - cameraComponent
could be null if it is not set in the inspector yada yada.
Line 10 - again, GetComponent
could return null yada yada.
Line 11 - cameraComponent
could be null if it is not set in the inspector or it might not have an AudioListener
yada yada.
Line 16 - what’s gameObject
yada yada?