title: How to spawn an object by instantiating its prefab via photon unity network - unity 3d
body: <p>In my multiplayer game, im trying to spawn my player by instantiating it. The error i get when running my program says i am missing the photon view component, yet i have it set to the correct player prefab. Here is my code for my network manager which searches, joins &amp; creates a room when ran. The OnJoinedRoom function is supposed to be spawning my player. </p>
  
  <p>error -'Failed to Instantiate prefab: Player. Prefab must have a PhotonView component.' </p>
  
  <p>code:</p>
  
  <p>using UnityEngine;
  using System.Collections;</p>
  
  <p>public class NetworkManager : Photon.MonoBehaviour 
  {</p>
  
  <pre><code>// Use this for initialization
  void Start () 
  {
      PhotonNetwork.ConnectUsingSettings ("version 1.0.0");
  }
  
  
  void OnGUI()
  {
      GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
  }
  
  void OnJoinedLobby()
  {
      PhotonNetwork.JoinRandomRoom ();
  }
  
  void OnPhotonRandomJoinFailed()
  {
      PhotonNetwork.CreateRoom (null);
  }
  
  void OnJoinedRoom()
  {
      GameObject myPlayer = PhotonNetwork.Instantiate ("Player", new Vector3(300, 18, 1496), Quaternion.identity, 0);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This link is a picture of the players information in the inspector. </p>
  
  <p><a href="http://prntscr.com/4wa8f6" rel="nofollow">http://prntscr.com/4wa8f6</a></p>