Cutting down on msg/s SerializeViews/PlayerPrefs et el.

Hi everyone, first post here... question about how to keep my messages per second down.

My game sends about 60-130msg/sec per player, and I am shooting for 4 player games. So clearly, I have to do somethings. As it stands, I have OnPhotonSerializeView called in four separate C# components.
If I changed some of the code to the PlayerPrefs system, would that cut down on the messages?

Example:

void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting) {
//We own this player: send the others our data
stream.SendNext (thrustFlag);
stream.SendNext (lastThrustFlag);

} else {
//Network player, receive data
thrustFlag = (bool)stream.ReceiveNext ();
lastThrustFlag = (bool)stream.ReceiveNext ();
}
}

Comments

  • 13.11.4.24 int PhotonNetwork.sendRate [static], [get], [set]
    Defines how many times per second PhotonNetwork should send a package. If you change this, do not forget to also change ’sendRateOnSerialize’.
    Less packages are less overhead but more delay. Setting the sendRate to 50 will create up to 50 packages per second (which is a lot!). Keep your target platform in mind: mobile networks are slower and less reliable.

    13.11.4.25 int PhotonNetwork.sendRateOnSerialize [static], [get], [set]
    Defines how many times per second OnPhotonSerialize should be called on PhotonViews.
    Choose this value in relation to ’sendRate’. OnPhotonSerialize will creart the commands to be put into packages. A lower rate takes up less performance but will cause more lag.
  • I found my answer by trial and error. It turns out that OnPhotonSerializeView was much less network intensive by several orders of magnitude over setting PlayerCustomProperties rapidly.
  • They are not for the same purpose actually.

    PlayerCustomProperties are server persistant data meant to store 'persistant informations'. They don't change rapidly normally and aren't meant for 'value communication with everyone else' but changes at descrete times when relevant.
    These properties are persistet on the photon server so even if the master changes its still there and every client can request these informations without contacting other players, in case a property change is not declared to be broadcasted
    This is handled by the first sendrate above as are RPC

    View Serialization is for realtime data syncronization, the 'on the fly world changes' to a specific object. This especially includes position, rotation, health etc data
    This is handled by the second send rate above.