Hello,
I am trying to sync my character bone rotations over the network. So for that I’ve wrote my own OnSerialize() an on OnDeserialize() function to sync the rotation list syncTransforms.
public override bool OnSerialize(NetworkWriter writer, bool initialState) {
base.OnSerialize(writer, initialState);
foreach (Transform trans in syncTransforms) {
writer.Write(trans.localRotation);
}
return true;
}
public override void OnDeserialize(NetworkReader reader, bool initialState) {
base.OnDeserialize(reader, initialState);
if (!isLocalPlayer) {
foreach (Transform trans in syncTransforms) {
trans.localRotation = reader.ReadQuaternion();
}
}
}
But unfortunately the OnSerialize() method is only called on server and not on the client which has the authority. So I have a few questions.
-
Is there a way that OnSerialize() runs on the client with authority?
If not my first idea is to send every frame from the authority client a command to the server with the rotation list. -
But if I do that how can I send the command only on the next network update step and not on every frame which would create an unnessessary command queue?
The OnSerialize() function is called every network update, is this right? -
And how can I declare the OnSerialize() function to send on the unreliable channel only?
In the case somebody knows a better way to update this rotations please let me know.
Thanks a lot!