Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unet Network Time sync?

Discussion in 'UNet' started by dnnkeeper, Sep 17, 2015.

  1. dnnkeeper

    dnnkeeper

    Joined:
    Jul 7, 2013
    Posts:
    82
    I can't find a way to sync time between client and server. It is essential for lag compensation. I used to have Network.Time but it doesn't work with the new hlapi. I tried using commands and rpc to calculate the difference but Time.time is very unstable and stops when you drag a window for example so any synchronisation breaks without any warning. And it's not trivial to get a good sync precision. Got any advice?
     
  2. dnnkeeper

    dnnkeeper

    Joined:
    Jul 7, 2013
    Posts:
    82
    Nevermind. It seems Network.Time works again for unet in 5.2 !
     
    HandyManStudios likes this.
  3. mitec02

    mitec02

    Joined:
    Oct 15, 2015
    Posts:
    8
    But it looks like, it doesn't work across platforms (e.g.: windows vs. linux)
     
  4. benzsuankularb

    benzsuankularb

    Joined:
    Apr 10, 2013
    Posts:
    132
    On same machine worked. But doesn't work between mac & window.
    Didn't try window with windows-windows yet.
     
  5. ThinhHB

    ThinhHB

    Joined:
    Oct 24, 2014
    Posts:
    9
    I've found the solution for this problem. I've post my answer here :
    http://answers.unity3d.com/questions/1109758/how-to-sync-unets-network-time.html#answer-1264391
    Let take a look.
    "The idea is : when a client connected to our Server, the server will send the current Network.time value to that client, the client will save the timeStamp received from Server, and update it on each frame (syncServerTime += Time.deltaTime ). So, we'll have the syncServerTime field that be sync on both Server and connected clients."
    ;)
     
    dnnkeeper likes this.