Advertisement
djgaven588

MultiplayerClient

Apr 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MultiplayerClient : MonoBehaviour {
  6.  
  7. public bool setup = false;
  8. public string clientName = "";
  9. private PhotonView myView;
  10. private PhotonView serverView;
  11. void Awake ()
  12. {
  13. if(GetComponent<PhotonView>().isMine)
  14. {
  15. setup = false;
  16. clientName = PhotonNetwork.player.NickName;
  17. myView = GetComponent<PhotonView>();
  18. JoinGame();
  19. }
  20. else
  21. {
  22. this.enabled = false;
  23. }
  24. }
  25.  
  26. [PunRPC]
  27. public void SyncClientInfo(bool ready, string name)
  28. {
  29. setup = ready;
  30. clientName = name;
  31. }
  32.  
  33. private void JoinGame()
  34. {
  35. //ConnectionObject = PhotonNetwork.Instantiate("ConnectionPrefab", Vector3.zero, Quaternion.identity, 0);
  36. myView.RPC("SyncClientInfo", PhotonTargets.AllBuffered, false, clientName);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement