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 & creates a room when ran. The OnJoinedRoom function is supposed to be spawning my player.
error -'Failed to Instantiate prefab: Player. Prefab must have a PhotonView component.'
code:
using UnityEngine; using System.Collections;
public class NetworkManager : Photon.MonoBehaviour {
// 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);
}
}
This link is a picture of the players information in the inspector.