Synchronization of player colours
Hello,i implmented a feature that changes the player colour depending if you are the master client or not.The problem is i need to somehow sync the player colour, because if not you see the player the same colour as you are.
I have this code but it does not seem to work.
I have this code but it does not seem to work.
private void Start() { spriteRenderer = GetComponent<SpriteRenderer>(); view = GetComponent<PhotonView>(); SetColour(); view.RPC("RPC_SetColor", RpcTarget.AllBuffered, spriteRenderer.color); } private void SetColour() { if (PhotonNetwork.IsMasterClient) { spriteRenderer.color = Color.blue; } else { spriteRenderer.color = Color.red; } } [PunRPC] void RPC_SetColor(Color transferredColor) { gameObject.GetComponent<SpriteRenderer>().color = transferredColor; }
0
Comments
-
You dont need to use buffered RPC. In fact, you dont need an RPC at all.
Just check photonView.Owner.IsMasterClient on start and then each time master client changes (OnMasterClientSwitched event).
1 -
Judging by your code, you have already done this.
You are welcome by the way.
1