Can't sync previous connected clients' color.
Here's my problem: evertything is fine for those clients who was connected to the server, but the new client connected can't get the previous clients' color and I have no ideia what to do about it. How can I send a client color to the server in the moment an other client connects to that server since OnServerConnect doens't work on NetworkBehaviours. It's probbly a dumb question but I got out of ideas.
public class Player_: NetworkBehaviour {
[SyncVar(hook = "OnChangeColor")] Vector3 myColor = Vector3.one;
private SpriteRenderer mySpr;
void Start()
{
mySpr = GetComponent<SpriteRenderer>();
myColor = (new Vector3(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f)));
}
void OnChangeColor(Vector3 newColor)
{
mySpr.color = new Color(color.x, color.y, color.z);
}
}
My code is something like this.
Comment