Dear… whoever
I’m really new to this networking stuff, just trying to find out.
I’ve got an application where you can start a server, and with a second build you can join the server. So far so good.
I now also have, when the server clicks a sphere object turns red, click again and it goes white. This is send so the client sees it as well. It’s this code:
// Update is called once per frame
void Update () {
if(Network.isServer) {
if(Input.GetMouseButtonUp(0)) {
NetworkViewID viewID = Network.AllocateViewID();
networkView.RPC("ChangeMaterial", RPCMode.All, viewID);
}
}
}
[RPC]
void ChangeMaterial(NetworkViewID viewID) {
if(!clicked) {this.renderer.material.color = Color.red; clicked = true;}
else {this.renderer.material.color = Color.white; clicked = false;}
}
There is one problem though.
If the server has clicked once before, the sphere is red. If the client then joins, on his screen it is still white.
If the server clicks again, on the server side the sphere becomes white but on the client side it goes red. and so on.
How should I synchronize the client with the server as soon as the player joins?
Hope I was clear, thanks in advance.