Mirror multiplayer player color update not showing on other clients

321 Views Asked by At

The code below is on the player and successfully updates the color of the several materials used for this player. This is called during the game to change the color after spawn and called again to change the player back to the original color.

 [Command]
 public void CmdHandlePlayerColorChange(Color newColor)
 {
     foreach (MeshRenderer mr in meshes)
     {
         currColor = newColor;
         mr.material.color = currColor;
     }
 }

However, the other clients do not pickup the color change (the color stays the same as set at spawntime). I tried Command/ClientRpc (below), but this crashed the other client.

 [ClientRpc]
 void RpcPlayerColorChange(Color newColor)
 {
     foreach (MeshRenderer mr in meshes)
     {
         currColor = newColor;
         mr.material.color = currColor;
     }
 }
 [Command]
 public void CmdHandlePlayerColorChange(Color newColor)
 {
     RpcPlayerColorChange(newColor);
 }

I appreciate any suggestions to get the other clients to pick up the color change.

0

There are 0 best solutions below