I use the following code to spawn Players. But when its called both master and client there are extra prefabs getting
spawned. Can someone help me?
Exactly 3 Target(clone) and Player(clone) are instantiated in the scene.
spawned. Can someone help me?
Exactly 3 Target(clone) and Player(clone) are instantiated in the scene.
[PunRPC]
public void RPC_SpawnTargets()
{
int i = 1;
TargetFormation=GameObject.Find("Target Formation").GetComponent<Transform>();
foreach (Transform child in TargetFormation )
{
GameObject target = PhotonNetwork.Instantiate(Path.Combine("Prefabs","Target"),child.transform.position,Quaternion.identity,0) as GameObject;
target.name = "Target ("+i+")";
target.transform.parent = child;
print("Target Function called "+i+" times");
i++;
}
i = 0;
}
[PunRPC]
public void RPC_SpawnPlayers()
{
int i = 1;
PlayerFormation=GameObject.Find("Player Formation").GetComponent<Transform>();
foreach (Transform child in PlayerFormation )
{
GameObject player =PhotonNetwork.Instantiate(Path.Combine("Prefabs","Player"),child.transform.position,Quaternion.identity,0) as GameObject;
player.name = "Player ("+i+")";
player.transform.parent = child;
i++;
}
i=0;
}