Hello,
Because Network.Time doesn’t work in Unet, i have a big problem of time synchronisation between server and clients.
I build this to compensate the lack of time synchronisation :
void BaseOnTimestampSynchronisation(NetworkMessage netMsg)
{
byte error;
if (!NetworkServer.active)
{
timestampDelta = netMsg.ReadMessage<IntegerMessage>().value;
timestampDelta += NetworkTransport.GetRemoteDelayTimeMS(client.connection.hostId, client.connection.connectionId, timestampDelta, out error);
timestampDelta = timestampDelta - NetworkTransport.GetNetworkTimestamp();
}
else
timestampDelta = 0;
}
The server send it’Timestamp on client who connect. The client calcul the difference between Timestamp + time to receive this TimeStamp and it’s current NetworkTransport.TimeStamp.
When i want the server Timestamp on a client i do :
public int ServerTimestamp
{
get { return NetworkTransport.GetNetworkTimestamp() + timestampDelta; }
}
Is this correct ? I have some doubts and i need a very accurate server time since i want movement synchronisation dead reckoning technique.