Search Unity

Can't change NetworkTransform.SendInterval serverside

Discussion in 'Multiplayer' started by crimsontwilight, Sep 14, 2017.

  1. crimsontwilight

    crimsontwilight

    Joined:
    Jun 17, 2014
    Posts:
    4
    Using this (https://unity3d.com/learn/tutorials...ion-simple-multiplayer-example?playlist=29690) tutorial I created a very basic 2D 'game', which only consisted of synced movement. To lower the lag I tried increasing the network send rate, which worked to an extent, but it is capped at 29 in the editor. I used NetworkTransform.SendInterval in my movement code, like so:

    Code (CSharp):
    1. void Start()
    2.     {       NetworkTransform netTrans = gameObject.GetComponent(typeof(NetworkTransform)) as NetworkTransform;
    3.         float interval = (1/64);
    4.         if (isLocalPlayer)
    5.         {
    6.             netTrans.sendInterval = interval;
    7.         }
    8.     }
    This (almost) eliminates any lag between the server and the client that is moving, but doesn't make a difference between the server and all the other clients. The SendInterval from server to client wasn't changed, I tried to fix it using:

    Code (CSharp):
    1.  
    2. void Start()
    3.     {      NetworkTransform netTrans = gameObject.GetComponent(typeof(NetworkTransform)) as NetworkTransform;
    4.         float interval = (1/64);
    5.         if (isLocalPlayer)
    6.         {
    7.             netTrans.sendInterval = interval;
    8.         }
    9.         if (isServer)
    10.         {
    11.             netTrans.sendInterval = interval;
    12.         }  
    13. }

    but this stops any NetworkTransform data being sent/received from Server => client i.e. player moves on server, but doesn't move at all on other clients. I know it is better practice to write good interpolation code rather than just increasing the send rate, but I want to know how to do this, it's just really bugging me.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I've never tried setting it above 29, but even if that does technically work you can be sure that sending updates 64 times per second isn't going to be a very viable solution to the problem.
     
  3. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Highering send rates above 20 is usually not a good solution. Using inter and/or extrapolation is usually a much better solution