Search Unity

Unet WLAN lag

Discussion in 'Scripting' 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. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    The Multiplayer/Networking sub-forum is a better place for this. It's scripting, so it isn't against the rules or anything, but you're a lot more likely to get help there.

    Also, be sure to paste code into the Insert->Code window or directly copy/paste from the script into tags. When you post it without tags it drops the whitespace/tabs, so even if you edit and add the tags properly it's still really annoying to read. When that happens, you need to re-copy from the original script.
     
    Last edited: Oct 18, 2016
  3. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
    Ty for telling me , reposted it under the proper section : https://forum.unity3d.com/threads/unet-wlan-lag.436980/ .