I have a pretty interesting problem.
NetworkBehaviours require a NetworkIdentity component. Not a problem actually. But when I add the NetworkIdentity component to the gameobject and I want to access the NetworkBehaviour class via GameObject.Find(“…”).getComponent<…>, I always get a NullReferenceException.
First, can you break up the expression to determine which part is returning null.
var myObject = GameObject.Find("...");
if (myObject == null) {
Debug.LogError("Could not find game object.");
} else {
var myComponent = myObject.GetComponent<...>();
if (myComponent == null) Debug.LogError("Could not get component");
}
I’ve read a lot about the networkingsystem but I still can’t figure out why it doesn’t work. NetworkServer.SpawnObjects() doesn’t give out an exception, the objects definitely have a NetworkIdentity component attached and the function is called. I wonder why it still doesn’t work.