mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Moved sendIntervalMultiplier, timelineOffset, timeStampAdjustment, offset to NTBase (#3442)
* Moved sendIntervalMultiplier, timelineOffset, timeStampAdjustment, offset to NetworkTransformBase * Update Assets/Mirror/Components/NetworkTransformBase.cs * fix: NetworkTransformUnreliable: timeStampAdjustment, timelineOffset to fix 2s jitter after tab switching in webgl caused by NT snaps potentially arriving behind timeline snaps (#3441) * NT-U: Implemented sendIntervalMultiplier, timeStampAdjustment, timelineOffset * Update Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com> --------- Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com> * Resolved conflict * Resolved conflict * NT: send interval multiplier moved to Base --------- Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
This commit is contained in:
parent
4eeb703488
commit
f23d044519
@ -57,6 +57,31 @@ public abstract class NetworkTransformBase : NetworkBehaviour
|
|||||||
[Tooltip("Set to false to remove scale smoothing. Example use-case: Instant flipping of sprites that use -X and +X for direction.")]
|
[Tooltip("Set to false to remove scale smoothing. Example use-case: Instant flipping of sprites that use -X and +X for direction.")]
|
||||||
public bool interpolateScale = true;
|
public bool interpolateScale = true;
|
||||||
|
|
||||||
|
[Header("Send Interval Multiplier")]
|
||||||
|
[Tooltip("Check/Sync every multiple of Network Manager send interval (= 1 / NM Send Rate), instead of every send interval.")]
|
||||||
|
[Range(1, 120)]
|
||||||
|
public uint sendIntervalMultiplier = 1; // not implemented yet
|
||||||
|
|
||||||
|
[Header("Timeline Offset")]
|
||||||
|
[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;
|
||||||
|
|
||||||
|
// Ninja's Notes on offset & mulitplier:
|
||||||
|
//
|
||||||
|
// In a no multiplier scenario:
|
||||||
|
// 1. Snapshots are sent every frame (frame being 1 NM send interval).
|
||||||
|
// 2. Time Interpolation is set to be 'behind' by 2 frames times.
|
||||||
|
// In theory where everything works, we probably have around 2 snapshots before we need to interpolate snapshots. From NT perspective, we should always have around 2 snapshots ready, so no stutter.
|
||||||
|
//
|
||||||
|
// In a multiplier scenario:
|
||||||
|
// 1. Snapshots are sent every 10 frames.
|
||||||
|
// 2. Time Interpolation remains 'behind by 2 frames'.
|
||||||
|
// When everything works, we are receiving NT snapshots every 10 frames, but start interpolating after 2.
|
||||||
|
// Even if I assume we had 2 snapshots to begin with to start interpolating (which we don't), by the time we reach 13th frame, we are out of snapshots, and have to wait 7 frames for next snapshot to come. This is the reason why we absolutely need the timestamp adjustment. We are starting way too early to interpolate.
|
||||||
|
//
|
||||||
|
protected double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1);
|
||||||
|
protected double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0;
|
||||||
|
|
||||||
// debugging ///////////////////////////////////////////////////////////
|
// debugging ///////////////////////////////////////////////////////////
|
||||||
[Header("Debug")]
|
[Header("Debug")]
|
||||||
public bool showGizmos;
|
public bool showGizmos;
|
||||||
|
@ -18,11 +18,6 @@ public class NetworkTransformReliable : NetworkTransformBase
|
|||||||
[Tooltip("If we only sync on change, then we need to correct old snapshots if more time than sendInterval * multiplier has elapsed.\n\nOtherwise the first move will always start interpolating from the last move sequence's time, which will make it stutter when starting every time.")]
|
[Tooltip("If we only sync on change, then we need to correct old snapshots if more time than sendInterval * multiplier has elapsed.\n\nOtherwise the first move will always start interpolating from the last move sequence's time, which will make it stutter when starting every time.")]
|
||||||
public float onlySyncOnChangeCorrectionMultiplier = 2;
|
public float onlySyncOnChangeCorrectionMultiplier = 2;
|
||||||
|
|
||||||
[Header("Send Interval Multiplier")]
|
|
||||||
[Tooltip("Check/Sync every multiple of Network Manager send interval (= 1 / NM Send Rate), instead of every send interval.")]
|
|
||||||
[Range(1, 120)]
|
|
||||||
public uint sendIntervalMultiplier = 3;
|
|
||||||
|
|
||||||
[Header("Rotation")]
|
[Header("Rotation")]
|
||||||
[Tooltip("Sensitivity of changes needed before an updated state is sent over the network")]
|
[Tooltip("Sensitivity of changes needed before an updated state is sent over the network")]
|
||||||
public float rotationSensitivity = 0.01f;
|
public float rotationSensitivity = 0.01f;
|
||||||
@ -42,26 +37,6 @@ public class NetworkTransformReliable : NetworkTransformBase
|
|||||||
[Range(0.00_01f, 1f)] // disallow 0 division. 1mm to 1m precision is enough range.
|
[Range(0.00_01f, 1f)] // disallow 0 division. 1mm to 1m precision is enough range.
|
||||||
public float scalePrecision = 0.01f; // 1 cm
|
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;
|
|
||||||
|
|
||||||
// Ninja's Notes on offset & mulitplier:
|
|
||||||
//
|
|
||||||
// In a no multiplier scenario:
|
|
||||||
// 1. Snapshots are sent every frame (frame being 1 NM send interval).
|
|
||||||
// 2. Time Interpolation is set to be 'behind' by 2 frames times.
|
|
||||||
// In theory where everything works, we probably have around 2 snapshots before we need to interpolate snapshots. From NT perspective, we should always have around 2 snapshots ready, so no stutter.
|
|
||||||
//
|
|
||||||
// In a multiplier scenario:
|
|
||||||
// 1. Snapshots are sent every 10 frames.
|
|
||||||
// 2. Time Interpolation remains 'behind by 2 frames'.
|
|
||||||
// When everything works, we are receiving NT snapshots every 10 frames, but start interpolating after 2.
|
|
||||||
// Even if I assume we had 2 snapshots to begin with to start interpolating (which we don't), by the time we reach 13th frame, we are out of snapshots, and have to wait 7 frames for next snapshot to come. This is the reason why we absolutely need the timestamp adjustment. We are starting way too early to interpolate.
|
|
||||||
//
|
|
||||||
double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1);
|
|
||||||
double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0;
|
|
||||||
|
|
||||||
// delta compression needs to remember 'last' to compress against
|
// delta compression needs to remember 'last' to compress against
|
||||||
protected Vector3Long lastSerializedPosition = Vector3Long.zero;
|
protected Vector3Long lastSerializedPosition = Vector3Long.zero;
|
||||||
protected Vector3Long lastDeserializedPosition = Vector3Long.zero;
|
protected Vector3Long lastDeserializedPosition = Vector3Long.zero;
|
||||||
|
@ -36,31 +36,6 @@ public class NetworkTransform : NetworkTransformBase
|
|||||||
protected bool hasSentUnchangedPosition;
|
protected bool hasSentUnchangedPosition;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[Header("Send Interval Multiplier")]
|
|
||||||
[Tooltip("Check/Sync every multiple of Network Manager send interval (= 1 / NM Send Rate), instead of every send interval.")]
|
|
||||||
[Range(1, 120)]
|
|
||||||
const uint sendIntervalMultiplier = 1; // not implemented yet
|
|
||||||
|
|
||||||
[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;
|
|
||||||
|
|
||||||
// Ninja's Notes on offset & mulitplier:
|
|
||||||
//
|
|
||||||
// In a no multiplier scenario:
|
|
||||||
// 1. Snapshots are sent every frame (frame being 1 NM send interval).
|
|
||||||
// 2. Time Interpolation is set to be 'behind' by 2 frames times.
|
|
||||||
// In theory where everything works, we probably have around 2 snapshots before we need to interpolate snapshots. From NT perspective, we should always have around 2 snapshots ready, so no stutter.
|
|
||||||
//
|
|
||||||
// In a multiplier scenario:
|
|
||||||
// 1. Snapshots are sent every 10 frames.
|
|
||||||
// 2. Time Interpolation remains 'behind by 2 frames'.
|
|
||||||
// When everything works, we are receiving NT snapshots every 10 frames, but start interpolating after 2.
|
|
||||||
// Even if I assume we had 2 snapshots to begin with to start interpolating (which we don't), by the time we reach 13th frame, we are out of snapshots, and have to wait 7 frames for next snapshot to come. This is the reason why we absolutely need the timestamp adjustment. We are starting way too early to interpolate.
|
|
||||||
//
|
|
||||||
double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1);
|
|
||||||
double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0;
|
|
||||||
|
|
||||||
// update //////////////////////////////////////////////////////////////
|
// update //////////////////////////////////////////////////////////////
|
||||||
// Update applies interpolation
|
// Update applies interpolation
|
||||||
void Update()
|
void Update()
|
||||||
|
Loading…
Reference in New Issue
Block a user