Integer sent over network is laggy/choppy

I am currently trying to send an Integer, which is the current index of an array of gameobjects, which is being iterated over inside of a for loop. When another player connects to my room, the integer (current index of the array) becomes choppy and skips causing my values to become unstable. I am using OnPhotonSerializeView but still having issues. I have made them observable the PhotonView.

For Reference, I am using the CurrentIndex value to adjust the size and mesh of a GameObject

Here is my current work so far:

private int _currentIndex;

public int CurrentIndex
  {
    get { return _currentIndex; }
    set
    {
      if (value != _currentIndex)
      {
        // Ensure current index isn't more/less than the index bounds of the given Sequence Items...
        if (_currentIndex >= 0 || _currentIndex <= SequenceItems.Length - 1)
        {
          _currentIndex = value;
        }
      }
    }
  }

 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
  {
    if (stream.IsWriting)
    {
      stream.SendNext(CurrentIndex);
    }
    else
    {
      CurrentIndex = (int)stream.ReceiveNext();
 
    }
  }

Comments

  • When another player connects to my room, the integer (current index of the array) becomes choppy and skips

    Is that initially or permanent?

    I mean, this could just be what it is: You get 10 updates per second and each applies the CurrentIndex whenever the update arrived. There is no smoothing at all. So, yes, this might simply look choppy.

    Fusion sends more effective updates and can send them 30-60 times a second. Still, you want to interpolate between updates, if needs be.

    You may want to somehow smooth this using Update().