title: PhotonNetworking Unity Player Spawn Not Working Over Network
body: <p><strong>HERE IS THE SOLVED CODE.</strong></p>
  
  <p>SOLVED[]</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class NetworkManager : MonoBehaviour {
      /*
      public Camera standbyCamera;*/
      // Use this for initialization
      SpawnSpot[] spawnSpots; 
      void Start () {
          Connect ();
          spawnSpots = GameObject.FindObjectsOfType&lt;SpawnSpot&gt; ();
      }
  
      void Connect(){
          PhotonNetwork.ConnectUsingSettings ("1.0.0");
      }
  
      void OnGui(){
          Debug.Log ("OnGui" + PhotonNetwork.connectionStateDetailed.ToString ());
          GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
      }
      // Update is called once per frame
      void OnJoinedLobby () {
          Debug.Log ("Joined Lobby");
          PhotonNetwork.JoinRandomRoom ();
      }
      void OnPhotonRandomJoinFailed(){
          Debug.Log ("Failed Join");
          PhotonNetwork.CreateRoom (null);
      }
      void OnJoinedRoom() {
          Debug.Log ("Joined Room");
          SpawnMyPlayer ();
      }
      private GameObject pivot;
      private GameObject topDownCam;
      public void SpawnMyPlayer(){
          SpawnSpot mySpawnSpot = spawnSpots [ Random.Range (0, spawnSpots.Length) ];
          GameObject myPlayer = PhotonNetwork.Instantiate ("Player", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
          //standbyCamera.enabled = false;
          myPlayer.gameObject.SetActive (true);
  
          topDownCam = GameObject.FindWithTag("TopDown");
          topDownCam.GetComponent&lt;Camera&gt;().enabled = true;
  
          try
          {
  
              pivot = GameObject.FindWithTag("PivotObject");
  
  
              pivot.GetComponent&lt;MouseLook&gt;().enabled = true;
  
              MouseLook mouseScript = myPlayer.GetComponentInChildren&lt;MouseLook&gt;();
              if(mouseScript != null)
              {
                  mouseScript.enabled = true;
              }
  
              CharMove moveScript = myPlayer.GetComponentInChildren&lt;CharMove&gt;();
              if(moveScript != null)
              {
                  moveScript.enabled = true;
              }
  
              CharacterController controlScript = myPlayer.GetComponentInChildren&lt;CharacterController&gt;();
              if(controlScript != null)
              {
                  controlScript.enabled = true;
              }
  
              Camera childCam = myPlayer.GetComponentInChildren&lt;Camera&gt;();
              if(childCam != null)
              {
                  childCam.enabled = true;
              }
  
          }
          catch
          {
              Debug.Log ("Error finding children");
          }
  
  
  
      }
  }
  </code></pre>
  
  <p>So I have a unity project im working on we are using photon networking I have attached an image of the structure of the player and the scripts associated with it. For some reason when i load two players they can't see each other. </p>
  
  <p>I know if I don't disable the player, I will see both but the control will be all screwed up, however if I disable the scripts associated with each element of the character, and leave the character enabled like the tutorial said I can't select the scripts for some reason I can't figure out how to get to the components.
  <img src="https://i.stack.imgur.com/5YMzq.png" alt="enter image description here"></p>
  
  <p>I do get a failed join in the console here is the output</p>
  
  <pre><code>Failed Join
  UnityEngine.Debug:Log(Object)
  NetworkManager:OnPhotonRandomJoinFailed() (at Assets/Game Assets/Prefab/Resources/Scripts/NetworkManager.cs:28)
  UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
  NetworkingPeer:SendMonoMessage(PhotonNetworkingMessage, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1865)
  NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1223)
  ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
  ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
  ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
  PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:83)
  </code></pre>
  
  <p>but then it joins and doesn't fail</p>
  
  <pre><code>Joined Room
  UnityEngine.Debug:Log(Object)
  NetworkManager:OnJoinedRoom() (at Assets/Game Assets/Prefab/Resources/Scripts/NetworkManager.cs:32)
  UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
  NetworkingPeer:SendMonoMessage(PhotonNetworkingMessage, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1865)
  NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1708)
  ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
  ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
  ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
  PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:83)
  </code></pre>
  
  <p>Here is my NetworkManager</p>
  
  <pre><code>    /*
      public Camera standbyCamera;*/
      // Use this for initialization
      SpawnSpot[] spawnSpots; 
      void Start () {
          Connect ();
          spawnSpots = GameObject.FindObjectsOfType&lt;SpawnSpot&gt; ();
      }
  
      void Connect(){
          PhotonNetwork.ConnectUsingSettings ("1.0.0");
      }
  
      void OnGui(){
          Debug.Log ("OnGui" + PhotonNetwork.connectionStateDetailed.ToString ());
          GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
      }
      // Update is called once per frame
      void OnJoinedLobby () {
          Debug.Log ("Joined Lobby");
          PhotonNetwork.JoinRandomRoom ();
      }
      void OnPhotonRandomJoinFailed(){
          Debug.Log ("Failed Join");
          PhotonNetwork.CreateRoom (null);
      }
      void OnJoinedRoom() {
          Debug.Log ("Joined Room");
          SpawnMyPlayer ();
      }
      void SpawnMyPlayer(){
          SpawnSpot mySpawnSpot = spawnSpots [ Random.Range (0, spawnSpots.Length) ];
          GameObject myPlayer = PhotonNetwork.Instantiate ("Player", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
          //standbyCamera.enabled = false;
          myPlayer.gameObject.SetActive (true);
          //((MonoBehaviour)myPlayer.GetComponent("CharacterController")).enabled = true;
          //((MonoBehaviour)myPlayer.GetComponent("CharMove")).enabled = true;
  
  
  
      }
  }
  </code></pre>
  
  <p>New Development
  If I join in unity and then join again with another player i get the following error</p>
  
  <pre><code>Received OnSerialization for view ID 2001. We have no such PhotonView! Ignored this if you're leaving a room. State: Joined
  UnityEngine.Debug:LogWarning(Object)
  NetworkingPeer:OnSerializeRead(Hashtable, PhotonPlayer, Int32, Int16) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3342)
  NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1758)
  ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
  ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
  ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
  PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:83)
  </code></pre>
  
  <p>I've changed the code a bit and it seems to be working except the camera</p>
  
  <pre><code>    SpawnSpot[] spawnSpots; 
      void Start () {
          Connect ();
          spawnSpots = GameObject.FindObjectsOfType&lt;SpawnSpot&gt; ();
      }
  
      void Connect(){
          PhotonNetwork.ConnectUsingSettings ("1.0.0");
      }
  
      void OnGui(){
          Debug.Log ("OnGui" + PhotonNetwork.connectionStateDetailed.ToString ());
          GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
      }
      // Update is called once per frame
      void OnJoinedLobby () {
          Debug.Log ("Joined Lobby");
          PhotonNetwork.JoinRandomRoom ();
      }
      void OnPhotonRandomJoinFailed(){
          Debug.Log ("Failed Join");
          PhotonNetwork.CreateRoom (null);
      }
      void OnJoinedRoom() {
          Debug.Log ("Joined Room");
          SpawnMyPlayer ();
      }
      public void SpawnMyPlayer(){
          SpawnSpot mySpawnSpot = spawnSpots [ Random.Range (0, spawnSpots.Length) ];
          GameObject myPlayer = PhotonNetwork.Instantiate ("Player", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
          //standbyCamera.enabled = false;
          myPlayer.gameObject.SetActive (true);
          //((MonoBehaviour)myPlayer.GetComponent("CharacterController")).enabled = true;
          ((MonoBehaviour)myPlayer.GetComponent("CharMove")).enabled = true;
  
          Transform[] allChildren = GetComponentsInChildren&lt;Transform&gt;();
          foreach (Transform child in allChildren) {
              ((MonoBehaviour)child.GetComponent("MouseLook")).enabled = true;
              child.transform.FindChild("Camera").gameObject.SetActive (true);
          }
  
          //myPlayer.transform.FindChild ("Camera").gameObject.SetActive (true);
  
      }
  }
  </code></pre>
  
  <p>When I spawn the second character  it doesnt start the camera and im technically controlling the second character from the first characters camera.</p>
  
  <p>As I keep coding away Ive come up with this</p>
  
  <pre><code>        spawnSpots = GameObject.FindObjectsOfType&lt;SpawnSpot&gt; ();
      }
  
      void Connect(){
          PhotonNetwork.ConnectUsingSettings ("1.0.0");
      }
  
      void OnGui(){
          Debug.Log ("OnGui" + PhotonNetwork.connectionStateDetailed.ToString ());
          GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
      }
      // Update is called once per frame
      void OnJoinedLobby () {
          Debug.Log ("Joined Lobby");
          PhotonNetwork.JoinRandomRoom ();
      }
      void OnPhotonRandomJoinFailed(){
          Debug.Log ("Failed Join");
          PhotonNetwork.CreateRoom (null);
      }
      void OnJoinedRoom() {
          Debug.Log ("Joined Room");
          SpawnMyPlayer ();
      }
      public void SpawnMyPlayer(){
          SpawnSpot mySpawnSpot = spawnSpots [ Random.Range (0, spawnSpots.Length) ];
          GameObject myPlayer = PhotonNetwork.Instantiate ("Player", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
          //standbyCamera.enabled = false;
          myPlayer.gameObject.SetActive (true);
          //((MonoBehaviour)myPlayer.GetComponent("CharacterController")).enabled = true;
  
  
  
          try
          {
              MouseLook mouseScript = myPlayer.GetComponentInChildren&lt;MouseLook&gt;();
              if(mouseScript != null)
              {
                  mouseScript.enabled = true;
              }
              CharMove moveScript = myPlayer.GetComponentInChildren&lt;CharMove&gt;();
              if(moveScript != null)
              {
                  moveScript.enabled = true;
              }
              CharacterController controlScript = myPlayer.GetComponentInChildren&lt;CharacterController&gt;();
              if(controlScript != null)
              {
                  controlScript.enabled = true;
              }
              Camera childCam = myPlayer.GetComponentInChildren&lt;Camera&gt;();
              if(childCam != null)
              {
                  childCam.enabled = true;
              }
  
          }
          catch
          {
              Debug.Log ("Error finding children");
          }
  
  
  
      }
  }
  </code></pre>
  
  <p>So I don't get any errors but it doesn't find the child of Turret, PivotPoint and Enable its mouse look it only enables the turret mouse look.</p>