Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Gamemanger.cs
- private PhotonView PV;
- private void Start()
- {
- PV = GetComponent<PhotonView>(); //create inital PhotonView object to reference later
- }
- void Update()
- {
- if (time <= 0)
- {
- ChangeTurn();
- time = 3;
- }
- else
- {
- time -= Time.deltaTime;
- }
- if (players.Count > numberOfPlayers) //if a new player joins give them a colour
- {
- Vector3 init = new Vector3(0, 0, 3);
- numberOfPlayers = players.Count;
- GameObject playerColour = colours[0];
- players[players.Count - 1].transform.position = init;
- colours.RemoveAt(0);
- PV.RPC("RPCSyncColours", RpcTarget.Others, playerColour.GetComponent<PhotonView>().ViewID); //pass ID
- //object[] content = new object[] { playerColour };
- //PhotonNetwork.RaiseEvent(evCode, content, RaiseEventOptions.Default, SendOptions.SendUnreliable);
- print("set child");
- }
- }
- [PunRPC]
- void RPCSyncColours(int ID)
- {
- print("Changed colours");
- }
- player.cs
- private void Update()
- {
- if (photonView.IsMine)
- {
- if (Input.GetKeyDown("space") && isTurn)
- {
- print("User pressed space!");
- }
- }
- }
- [PunRPC]
- public void RPCSyncColours(int ID)
- {
- print("added colour " + ID);
- PhotonView colour = PhotonView.Find(ID);
- colour.gameObject.transform.parent = this.gameObject.transform; //set colour to this object as child
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement