Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. Gamemanger.cs
  2.  
  3. private PhotonView PV;
  4.  
  5.     private void Start()
  6.     {
  7.         PV = GetComponent<PhotonView>(); //create inital PhotonView object to reference later
  8.     }
  9.  
  10.     void Update()
  11.     {
  12.  
  13.        
  14.         if (time <= 0)
  15.         {
  16.             ChangeTurn();
  17.             time = 3;
  18.         }
  19.         else
  20.         {
  21.             time -= Time.deltaTime;
  22.         }
  23.        
  24.         if (players.Count > numberOfPlayers) //if a new player joins give them a colour
  25.         {
  26.             Vector3 init = new Vector3(0, 0, 3);
  27.             numberOfPlayers = players.Count;
  28.  
  29.             GameObject playerColour = colours[0];
  30.            
  31.             players[players.Count - 1].transform.position = init;
  32.  
  33.             colours.RemoveAt(0);
  34.  
  35.             PV.RPC("RPCSyncColours", RpcTarget.Others, playerColour.GetComponent<PhotonView>().ViewID); //pass ID
  36.  
  37.             //object[] content = new object[] { playerColour };
  38.  
  39.             //PhotonNetwork.RaiseEvent(evCode, content, RaiseEventOptions.Default, SendOptions.SendUnreliable);
  40.  
  41.             print("set child");
  42.         }
  43.  
  44.     }
  45.  
  46. [PunRPC]
  47.     void RPCSyncColours(int ID)
  48.     {
  49.         print("Changed colours");
  50.     }
  51.  
  52.  
  53. player.cs
  54.  
  55.  private void Update()
  56.     {
  57.         if (photonView.IsMine)
  58.         {
  59.             if (Input.GetKeyDown("space") && isTurn)
  60.             {
  61.                 print("User pressed space!");
  62.             }
  63.         }
  64.  
  65.  
  66.     }
  67.  
  68.  [PunRPC]
  69.     public void RPCSyncColours(int ID)
  70.     {
  71.         print("added colour " + ID);
  72.  
  73.         PhotonView colour = PhotonView.Find(ID);
  74.  
  75.         colour.gameObject.transform.parent = this.gameObject.transform; //set colour to this object as child
  76.  
  77.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement