This is really strange. I have two objects, one which can be controlled by the server player, and another which can be controlled by the client player. When the server moves their object, it moves fine and the data is sent over the network. When the client moves their object, the client sees it move but nothing changes on the server. I checked all my scripts and there’s no other OnSerializeNetworkViews() then this one…
private int packet_num = 0;
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
if (stream.isWriting) {
Debug.Log ("Sending data: " + packet_num++);
Vector3 pos = new Vector3();
Quaternion rot = new Quaternion();
pos = this.transform.position;
rot = this.transform.rotation;
stream.Serialize(ref pos);
stream.Serialize(ref rot);
} else if (stream.isReading) {
Vector3 pos = new Vector3();
Quaternion rot = new Quaternion();
stream.Serialize (ref pos);
this.transform.position = pos;
stream.Serialize (ref rot);
this.transform.rotation = rot;
}
}
I checked to make sure there wasn’t any difference between the two objects by copy pasting the server object. Still no change. Also it should be noted, that when you’re running the client, and you have the console open, “Sending data” never shows up. This baffles me. Is there something about Unity’s State Synchronization that I just don’t understand?