mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
breaking: NetworkTransform sendIntervalMultiplier replaced by syncInterval math (#3895)
* repro
* force sendIntervalMultiplier based on syncInterval!
* Revert "repro"
This reverts commit e51c996fa6
.
* cleanup
* fix
* hide
* property
* rmv
---------
Co-authored-by: mischa <info@noobtuts.com>
This commit is contained in:
parent
2cdf811671
commit
f33ed68a1b
@ -67,10 +67,39 @@ public abstract class NetworkTransformBase : NetworkBehaviour
|
||||
[Tooltip("Local by default. World may be better when changing hierarchy, or non-NetworkTransforms root position/rotation/scale values.")]
|
||||
public CoordinateSpace coordinateSpace = CoordinateSpace.Local;
|
||||
|
||||
[Header("Send Interval Multiplier")]
|
||||
[Tooltip("Check/Sync every multiple of Network Manager send interval (= 1 / NM Send Rate), instead of every send interval.\n(30 NM send rate, and 3 interval, is a send every 0.1 seconds)\nA larger interval means less network sends, which has a variety of upsides. The drawbacks are delays and lower accuracy, you should find a nice balance between not sending too much, but the results looking good for your particular scenario.")]
|
||||
[Range(1, 120)]
|
||||
public uint sendIntervalMultiplier = 1;
|
||||
// TODO sendIntervalMultiplier was replaced by syncInterval for consistency with other NetworkBehaviours.
|
||||
// for now, we simply calculate the multiplier based on syncInterval.
|
||||
// in a future, we can remove this completely and replace with syncInterval math everywhere.
|
||||
// the multiplier math isn't that simple, so for now this is a good solution!
|
||||
public uint sendIntervalMultiplier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (syncInterval > 0)
|
||||
{
|
||||
// if syncInterval is > 0, calculate how many multiples of NetworkManager.sendRate it is
|
||||
//
|
||||
// for example:
|
||||
// NetworkServer.sendInterval is 1/60 = 0.16
|
||||
// NetworkTransform.syncInterval is 0.5 (500ms).
|
||||
// 0.5 / 0.16 = 3.125
|
||||
// in other words: 3.125 x sendInterval
|
||||
//
|
||||
// note that NetworkServer.sendInterval is usually set on start.
|
||||
// to make this work in Edit mode, make sure that NetworkManager
|
||||
// OnValidate sets NetworkServer.sendInterval immediately.
|
||||
float multiples = syncInterval / NetworkServer.sendInterval;
|
||||
|
||||
// syncInterval is always supposed to sync at a minimum of 1 x sendInterval.
|
||||
// that's what we do for every other NetworkBehaviour since
|
||||
// we only sync in Broadcast() which is called @ sendInterval.
|
||||
return multiples > 1 ? (uint)Mathf.RoundToInt(multiples) : 1;
|
||||
}
|
||||
|
||||
// if syncInterval is 0, use NetworkManager.sendRate (x1)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
[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")]
|
||||
@ -116,13 +145,6 @@ protected virtual void Configure()
|
||||
// set target to self if none yet
|
||||
if (target == null) target = transform;
|
||||
|
||||
// time snapshot interpolation happens globally.
|
||||
// value (transform) happens in here.
|
||||
// both always need to be on the same send interval.
|
||||
// force the setting to '0' in OnValidate to make it obvious that we
|
||||
// actually use NetworkServer.sendInterval.
|
||||
syncInterval = 0;
|
||||
|
||||
// Unity doesn't support setting world scale.
|
||||
// OnValidate force disables syncScale in world mode.
|
||||
if (coordinateSpace == CoordinateSpace.World) syncScale = false;
|
||||
|
Loading…
Reference in New Issue
Block a user