Different send rate per photonview

Options
Are we able to have different sendrate for different photonviews? I would want different objects to updated at different rates to optimize the data trasnfer.

Comments

  • Tobias
    Options
    Currently, that's not built-in. You could modify the code to skip every n-th update in your OnPhotonSerializeView. Just don't insert an update into the stream.
  • farflunggames
    Options
    Is this still the official way of reducing send rate? I'm thinking of doing that for NPCs (enemies in this case), while the player characters have a higher update frequency.
  • @Tobias if the sending side skips writing to the stream within OnPhotonSerializeView, based on some arbitrary condition - will OnPhotonSerializeView still be called on the receiving side? I want to do conditional updates, kind of similar to the concept of "update on change" so I can skip writing things into the stream if no update is required. I'm aware of the built-in behaviour within PhotonTransformView, but I need to do something similar within custom send/receive scenarios.
  • PoonamPal
    Options
    @Tobias when i try to do that i get "array index out of range" exception for photon stream. please guide us with some example.
  • Operation283
    edited April 2018
    Options
    I think I have a solution (although it may not be the most efficient). You get an out of range exception because OnPhotonSerializeView will be called regardless of whether you write anything to the stream or not. My idea is to write a boolean every serialize to indicate whether your data will follow. When reading, receive that boolean and only continue receiving the other objects if that boolean is true.

    Example:
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
    	if (stream.isWriting)
    	{
    		stream.SendNext(shouldSend);
    		if (shouldSend)
    		{
    			//Send other data
    		}
    	}
    	else
    	{
    		bool shouldReceive = (bool)stream.ReceiveNext();
    		if (shouldReceive)
    		{
    			//Receive other data
    		}
    	}
    }
  • lennart862
    Options
    Just use Raise Event instead of OnPhotonSerializeView