- Home /
Question by
NINJ4Z · May 14, 2014 at 01:08 PM ·
c#networkingphoton
Photon Networking Spawn player 2
I'm trying to figure out how to check whether player 1 exists already or not, I'm assuming you have to either do this with Player ID or add it to a buffer of some kind. Any help would be appreciated.
void OnJoinedRoom()
{
GameObject play1 = PhotonNetwork.Instantiate(player1, spawnPos, Quaternion.identity, 0);
//GameObject play2 = PhotonNetwork.Instantiate(player2, spawnPos2, Quaternion.identity, 0);
}
Comment
I'm not sure I understand what you are trying to do.
GameObject play1 = PhotonNetwork.Instantiate(player1, spawnPos, Quaternion.identity, 0);
This will instantiate player 1 to all of the network users currently connected to your room.
What you could do, is create a Game$$anonymous$$anager object that stores all of the players as they join. We need more info than what you have provided really.
public void Spawn () {
if (PhotonNetwork.is$$anonymous$$asterClient)
{
GameObject NewPlayer = PhotonNetwork.Instantiate ("Player", new Vector3 (-9f, 1f, -1f), Quaternion.identity, 0);
NewPlayer.transform.position = spawnL.position;
NewPlayer.transform.rotation = spawnL.rotation;
NewPlayer.tag = "Player1";
}
if (!PhotonNetwork.is$$anonymous$$asterClient)
{
GameObject NewPlayer = PhotonNetwork.Instantiate ("Player", new Vector3 (9f, 1f, -1f), Quaternion.identity, 0);
NewPlayer.transform.position = spawnR.position;
NewPlayer.transform.rotation = spawnR.rotation;
NewPlayer.tag = "Player2";
}
}
Spawn position works. But my build's player's tag still "Untagged" Editor player's tag correct always.