Can FixedUpdate be synhcronized across devices

Hi!

So we are writing a multiplayer game and have some logic that needs to synchronize between devices, and also run on the server.

To do this we intend to call an “Update” or “Tick” function in this code an equal amount of times on each system it is running on, hence creating identical output.

On Unity’s end we want to use the built-in FixedUpdate function, however we are finding that the Time.fixedDeltaTime is not consistent.

We have tested with the following code:

protected void FixedUpdate () {
    if (_stopWatch == null) {
        _stopWatch = new Stopwatch();
        _stopWatch.Start();
    } else {
        var seconds = (_stopWatch.ElapsedTicks + 0.0f) / Stopwatch.Frequency;
        if (Math.Abs(seconds - Time.deltaTime) > 0.001)
            UnityEngine.Debug.Log("FixedUpdate is jittery: " + seconds + " != " + Time.deltaTime);
        }
        _stopWatch.Reset();
        _stopWatch.Start();
    }
}

And the output is:
89859-jittery-fixedupdate.png

So what is going on here? It appears like FixedUpdate averages out to less than the expected frequency. How can this be if Time.fixedTime is reporting otherwise?

Is there a different way to create a guaranteed update on both devices and server?

Thanks in advance, any help or steering in the right direction will be appreciated!

There is no way to guarantee that. But what I can assure you is that the fixedUpdate gets called the same number of times each second. Just count the number of seconds. What you should worry about is latency.