PUN2 Failed to instantiate Prefab must have PhotonView Component
Options
I'm creating a SteamVR multiplayer game and I have been following the PUN tutorial (making changes as needed since the tutorial is for PUN1). When I load the scene OnlineRoom1 I have
PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
in the Start(). This is in the GameManager script which I've attached to the GameObject named "Game Manager" which spawns in the scene. in the public GameObject field I placed the prefab Player from the Project>Resources folder. Despite this prefab having a PhotonView component attached to it I get the error
Failed to Instantiate prefab:Player. Prefab must have a PhotonView component.
This error comes from the script PhotonNetwork.cs Instantiate() function.
if (prefabGo.GetComponent() == null)
{
Debug.LogError("Failed to Instantiate prefab:" + prefabName + ". Prefab must have a PhotonView component.");
return null;
}
Any ideas?
PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
in the Start(). This is in the GameManager script which I've attached to the GameObject named "Game Manager" which spawns in the scene. in the public GameObject field I placed the prefab Player from the Project>Resources folder. Despite this prefab having a PhotonView component attached to it I get the error
Failed to Instantiate prefab:Player. Prefab must have a PhotonView component.
This error comes from the script PhotonNetwork.cs Instantiate() function.
if (prefabGo.GetComponent() == null)
{
Debug.LogError("Failed to Instantiate prefab:" + prefabName + ". Prefab must have a PhotonView component.");
return null;
}
Any ideas?
0
Comments
-
Try using playerPrefab.name. Maybe the "this" is causing issues with it.0
-
0
-
https://ibb.co/enBoLU
image of the Player Prefab0 -
Nested deep in my other plugins was a prefab in a resources folder named Player. Just used a more unique name and all is well0