- Home /
Question by
chris56728 · Nov 11, 2013 at 10:22 AM ·
c#networkingphoton
Unity Networking RPC - Photon Cloud PUN
Hello guys,
In my game i'm trying to have a master client where other players join and then when they join the master client adds the player prefab to a list so that the master client can move them and what not.
This isn't working because it's not adding the instanced character to the master client array. I'm guessing I need to use some kind of RPC to make this happen? Any thoughts?
The way I've been approaching it is by:
public List<GameObject> TotalPlayers = new List<GameObject>();
public GameObject playerPrefab;
public GameObject spawnPoint;
public GameObject playerInstanceAddToList;
void OnJoinedRoom()
{
if (PhotonNetwork.isMasterClient)
{
Debug.Log("This is the master so no one should be instanced!");
}
else
{
Debug.Log ("Player should be instanced!");
Spawnplayer();
}
}
void Spawnplayer()
{
playerInstanceAddToList = PhotonNetwork.Instantiate(playerPrefab.name, spawnPoint.transform.position, transform.rotation, 0) as GameObject;
TotalPlayers.Add(playerInstanceAddToList);
}
Comment
Your answer
Follow this Question
Related Questions
Photon Cloud, Multiplayer Damage script 0 Answers
C# networking - static variable 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Unity3d Csharp Networking Error 3 Answers