Hi, i am creating a game where the player can choose to be in the blue team or the red team, so I have a button “RedTeam” and a button “BlueTeam” who will affect the variable “myTeam” of the player who pressed the button, this is working but i can’t seem to figure out how to change the renderer of the player to assign the color of his team over the network, it only works locally. Here is the piece of code of my script:
public void SetColor()
{
if (isLocalPlayer == true) {
CmdPlayerColors ();
}
}
[Command]
void CmdPlayerColors()
{
if(myTeam == "Blue"){
rend.material.SetColor("_Color", Color.blue);
//Debug.Log (transform.name + " is blue");
}
if(myTeam == "Red"){
rend.material.SetColor("_Color", Color.red);
//Debug.Log(transform.name +" is red");
}
}
Thanks in advance.
Why there is a "objNetId" ?
– antiNTOk, so I used your method and only the client can change it's color, the server will always be white (the default color)... Any ideas?
– antiNT