fix: #3427 NetworKTransformReliable now has a timelineOffset to account for decoupled arrival of NetworkTime and NetworkTransform snapshots (#3428)

* fix: #3427 NetworKTransformReliable now has a timelineOffset to account for decoupled arrival of NetworkTime and NetworkTransform snapshots

* bool
This commit is contained in:
mischa 2023-03-20 03:36:21 +01:00 committed by GitHub
parent 1a34614e4c
commit 30d7b5b3a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,10 @@ public class NetworkTransformReliable : NetworkTransformBase
[Range(0.00_01f, 1f)] // disallow 0 division. 1mm to 1m precision is enough range.
public float scalePrecision = 0.01f; // 1 cm
[Header("Snapshot Interpolation")]
[Tooltip("Add a small timeline offset to account for decoupled arrival of NetworkTime and NetworkTransform snapshots.\nfixes: https://github.com/MirrorNetworking/Mirror/issues/3427")]
public bool timelineOffset = false;
// delta compression needs to remember 'last' to compress against
protected Vector3Long lastSerializedPosition = Vector3Long.zero;
protected Vector3Long lastDeserializedPosition = Vector3Long.zero;
@ -298,7 +302,13 @@ protected virtual void OnClientToServerSync(Vector3? position, Quaternion? rotat
// Debug.Log($"{name}: corrected history on server to fix initial stutter after not sending for a while.");
}
AddSnapshot(serverSnapshots, connectionToClient.remoteTimeStamp, position, rotation, scale);
// add a small timeline offset to account for decoupled arrival of
// NetworkTime and NetworkTransform snapshots.
// needs to be sendInterval. half sendInterval doesn't solve it.
// https://github.com/MirrorNetworking/Mirror/issues/3427
// remove this after LocalWorldState.
double offset = timelineOffset ? NetworkServer.sendInterval : 0;
AddSnapshot(serverSnapshots, connectionToClient.remoteTimeStamp + offset, position, rotation, scale);
}
// server broadcasts sync message to all clients
@ -322,7 +332,13 @@ protected virtual void OnServerToClientSync(Vector3? position, Quaternion? rotat
// Debug.Log($"{name}: corrected history on client to fix initial stutter after not sending for a while.");
}
AddSnapshot(clientSnapshots, NetworkClient.connection.remoteTimeStamp, position, rotation, scale);
// add a small timeline offset to account for decoupled arrival of
// NetworkTime and NetworkTransform snapshots.
// needs to be sendInterval. half sendInterval doesn't solve it.
// https://github.com/MirrorNetworking/Mirror/issues/3427
// remove this after LocalWorldState.
double offset = timelineOffset ? NetworkServer.sendInterval : 0;
AddSnapshot(clientSnapshots, NetworkClient.connection.remoteTimeStamp + offset, position, rotation, scale);
}
// only sync on change /////////////////////////////////////////////////