[Solved]Networking - Null Reference Exception

Hello,
I am getting this weird nullreferenceexception, I have been trying for hours to fix it but it has been to no prevail! Anyway here is the error:
alt text

I’m pretty sure that there is a instance of the object since there is one created in the same function, here is the three snippets of code that link together to spawn my player(this is where it breaks).

	void OnConnectedToServer(){
		myPlayer = Network.player;
		networkView.RPC("MakePlayer", RPCMode.Server, myPlayer);
	}

	[RPC]
	void MakePlayer(NetworkPlayer thisPlayer){
		Transform newPlayer = Network.Instantiate(player, transform.position, transform.rotation, 0) as Transform;
		if(thisPlayer != myPlayer){
			networkView.RPC("EnableCamera", thisPlayer, newPlayer.networkView.viewID);
		} else {
			EnableCamera(newPlayer.networkView.viewID);
		}
	}

	[RPC]
	void EnableCamera(NetworkViewID playerID){
		GameObject[] players;
		players = GameObject.FindGameObjectsWithTag("Player");
		foreach(GameObject thisPlayer in players){
			if(thisPlayer.networkView.viewID == playerID){
				thisPlayer.transform.FindChild("Camera").GetComponent<Camera>().enabled = true;
				thisPlayer.GetComponentInChildren<AudioListener>().enabled = true;
				break;
			}
		}
	}

The line 113 that the error message points to is the EnableCamera(newPlayer.networkView.viewID); part in the MakePlayer function.

Thanks and I look forward to hearing your earliest response.

SOLUTION

The problem was that the newPlayer was being stored as a transform when it should be stored as a GameObject.

I would definitely go to your camera and confirm that it is tagged with “MainCamera”
If this isn’t the issue then I think this newPlayer variable may be empty.

The camera is tagged MainCamera, but how can newPlayer be empty when a transform is instantiated when the variable is created ?