Hello,
I want to instantiate a different game object for each player, so I made 2 prefabs in the resources folder (redPlayer & bluePlayer).
In my GameManager, I declared two public gameObjects, RedPlayer and BluePlayer and assigned the prefabs from the resources folder to those GameObject on the script.
An I have made another GameObject for the player prefab. here is the code
if (PlayerManager.LocalPlayerInstance == null)
{
if (GameObject.Find("redPlayer"))
{
playerPrefab = BluePlayer;
PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
}
else
{
playerPrefab = RedPlayer;
PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
}
}
However, when playing, I get an error message that the playerPrefab wasn’t assigned.