photon Spawn 4 players in different positions
Hello .. I am building 4 players online game on Unity .. I have figured to spawn two players only in different places .. but I need to spawn another two players in another different places .. PLEASE HELP
here is my C-Sharp code:
void SpawnPlayer()
{
if (PhotonNetwork.IsMasterClient) { playerPrefab = PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0, -800, -315), Quaternion.identity);
}
else
if (!PhotonNetwork.IsMasterClient)
{
playerPrefab = PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0, -800, 315), Quaternion.identity);
}
}
here is my C-Sharp code:
void SpawnPlayer()
{
if (PhotonNetwork.IsMasterClient) { playerPrefab = PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0, -800, -315), Quaternion.identity);
}
else
if (!PhotonNetwork.IsMasterClient)
{
playerPrefab = PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0, -800, 315), Quaternion.identity);
}
}
0
Comments
-
I am still learning myself but it seems to me that you could just add another line for each condition to instantiate another playerprefab just with a different vector3
0 -
The solution is :
- public Transform[] spawnPoints;
var point = spawnPoints[PhotonNetwork.LocalPlayer.ActorNumber - 1];
PhotonNetwork.Instantiate(prefab.name, point.position, point.rotation);
0