Advertisement
Guest User

C# PN

a guest
Nov 18th, 2018
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.     public void SpawnPlayer()
  2.     {
  3.         GameObject MyPlayerGO = PhotonNetwork.Instantiate("PlayerTwo", new Vector3(0f, 0f, 100f), Quaternion.identity, 0);
  4.         MyPlayerGO.transform.Find("PlayerTwo/Camera").gameObject.SetActive(true);
  5.         GetComponent<PhotonView>().RPC("SpawnPlayerRPC", PhotonTargets.AllBuffered, Player.MyPlayer.nick, MyPlayerGO.GetComponent<PhotonView>().viewID);
  6.     }
  7.  
  8.     [PunRPC]
  9.     public void SpawnPlayerRPC(string nick, int pvID, PhotonMessageInfo pmi)
  10.     {
  11.         GameObject NewPlayerGO = PhotonView.Find(pvID).gameObject;
  12.         NewPlayerGO.name = "Gracz_" + nick;
  13.         Player player = Player.FindPlayer(pmi.sender);
  14.         player.gameObject = NewPlayerGO;
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement