This commit is contained in:
mischa 2024-10-18 12:56:00 +02:00
parent 0ada67c7b9
commit 3c5869203d

View File

@ -61,8 +61,7 @@ public class NetworkTransformHybrid2022 : NetworkBehaviour
[Tooltip("Ocassionally send a full reliable state to delta compress against. This only applies to Components with SyncMethod=Unreliable.")] [Tooltip("Ocassionally send a full reliable state to delta compress against. This only applies to Components with SyncMethod=Unreliable.")]
public int baselineRate = 1; public int baselineRate = 1;
public float baselineInterval => baselineRate < int.MaxValue ? 1f / baselineRate : 0; // for 1 Hz, that's 1000ms public float baselineInterval => baselineRate < int.MaxValue ? 1f / baselineRate : 0; // for 1 Hz, that's 1000ms
double lastServerBaselineTime; double lastBaselineTime;
double lastClientUnreliableTime;
// delta compression needs to remember 'last' to compress against. // delta compression needs to remember 'last' to compress against.
// this is from reliable full state serializations, not from last // this is from reliable full state serializations, not from last
@ -250,7 +249,7 @@ void SerializeServerBaseline(NetworkWriter writer, Vector3 position, Quaternion
// included in baseline to identify which one it was on client // included in baseline to identify which one it was on client
// included in deltas to ensure they are on top of the correct baseline // included in deltas to ensure they are on top of the correct baseline
lastSerializedBaselineTick = frameCount; lastSerializedBaselineTick = frameCount;
lastServerBaselineTime = NetworkTime.localTime; lastBaselineTime = NetworkTime.localTime;
// set 'last' // set 'last'
lastPosition = position; lastPosition = position;
@ -500,7 +499,7 @@ protected virtual void OnServerToClientDeltaSync(byte baselineTick, Vector3? pos
void UpdateServerBaseline(double localTime) void UpdateServerBaseline(double localTime)
{ {
// send a reliable baseline every 1 Hz // send a reliable baseline every 1 Hz
if (localTime >= lastServerBaselineTime + baselineInterval) if (localTime >= lastBaselineTime + baselineInterval)
{ {
// perf: get position/rotation directly. TransformSnapshot is too expensive. // perf: get position/rotation directly. TransformSnapshot is too expensive.
// TransformSnapshot snapshot = ConstructSnapshot(); // TransformSnapshot snapshot = ConstructSnapshot();