Search Unity

Unet WLAN lag

Discussion in 'UNet' started by abhijeet1001, Oct 18, 2016.

  1. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
    Hi everyone ,

    I been working with Unet for a couple of weeks now and facing a issue of lag when playing game on WLAN , i connect using networkdiscovery once game starts , other players start lagging on my screen ( they will teleport , stutter etc ) its random , will happen for few seconds > stop > happen again ? . So far i have tried everything without any luck :( . Here are somethings i tried .

    I am using unity networktransform :

    Network Sendrate - 9

    syncing rigidbody 3d
    movment threshold - 0.001
    snap threshold - 5
    interpolate movement - 0.5

    rotation

    rotation axis - y ( topdown 2d )
    interpolate rotation - 10

    rest default


    I tried the above settings and faced lag in game so i ramped the sendrate to 29 , and same problem !!!! like increasing sendrate did nothing .


    Then i tried making custom network transform by simply doing the following :

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.EventSystems;
    3. using UnityEngine.Networking;
    4.  
    5. public class networkMovement : NetworkBehaviour
    6. {
    7.  
    8.     [SyncVar]
    9.     Vector3 realPosition = Vector3.zero;
    10.     [SyncVar]
    11.     Quaternion realRotation;
    12.     private float updateInterval;
    13.  
    14.     void Start()
    15.     {
    16.     }
    17.  
    18.     void Update () {
    19.         if (isLocalPlayer) {
    20.             //code...
    21.             realPosition = transform.position;
    22.             realRotation = transform.rotation;
    23.             CmdSync(transform.position, transform.rotation);
    24.         } else {
    25.             transform.position = Vector3.Lerp(transform.position, realPosition, .1f);
    26.             transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, .1f);
    27.         }
    28.     }
    29.  
    30.  
    31.     [Command]
    32.     void CmdSync(Vector3 position, Quaternion rotation)
    33.     {
    34.         realPosition = position;
    35.         realRotation = rotation;
    36.     }
    37. }
    But still no luck . So i finally decided to post it here in hopes of finding the solution here . Any help is appreciated .
     
  2. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
  3. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    27
  4. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
    Hi , ty for pointing that out , but apparently its not working for me :( . Cant figure out whats causing the lag , all i am syncing is via component network transform with interpolation on :x still the movement of objects get jittery and rough
     
  5. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    27
    Did you try setting SendDelay to a smaller value than the default 10.0f in the network configuration?