mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: NetworkClient now only tries to broadcast every sendInterval. otherwise ClientToServer NetworkTransform components (which have syncInterval=0) would sync every single tick. prepare for NT V3 as well.
This commit is contained in:
parent
3d3a542ddd
commit
723da0cecc
@ -1424,19 +1424,7 @@ static void DestroyObject(uint netId)
|
||||
// broadcast ///////////////////////////////////////////////////////////
|
||||
static void BroadcastTimeSnapshot()
|
||||
{
|
||||
// always send when running tests though.
|
||||
// keep this interval independent from state broadcast for now.
|
||||
// so that state broadcast syncIntervals are respected.
|
||||
if (!Application.isPlaying ||
|
||||
#if !UNITY_2020_3_OR_NEWER
|
||||
// Unity 2019 doesn't have Time.timeAsDouble yet
|
||||
AccurateInterval.Elapsed(NetworkTime.localTime, sendInterval, ref lastSendTime))
|
||||
#else
|
||||
AccurateInterval.Elapsed(Time.timeAsDouble, sendInterval, ref lastSendTime))
|
||||
#endif
|
||||
{
|
||||
Send(new TimeSnapshotMessage(), Channels.Unreliable);
|
||||
}
|
||||
Send(new TimeSnapshotMessage(), Channels.Unreliable);
|
||||
}
|
||||
|
||||
// make sure Broadcast() is only called every sendInterval.
|
||||
@ -1515,7 +1503,29 @@ internal static void NetworkLateUpdate()
|
||||
// limit to every component's sendInterval automatically.
|
||||
if (active)
|
||||
{
|
||||
Broadcast();
|
||||
// broadcast every sendInterval.
|
||||
// AccurateInterval to avoid update frequency inaccuracy issues:
|
||||
// https://github.com/vis2k/Mirror/pull/3153
|
||||
//
|
||||
// for example, host mode server doesn't set .targetFrameRate.
|
||||
// Broadcast() would be called every tick.
|
||||
// snapshots might be sent way too often, etc.
|
||||
//
|
||||
// during tests, we always call Broadcast() though.
|
||||
//
|
||||
// also important for syncInterval=0 components like
|
||||
// NetworkTransform, so they can sync on same interval as time
|
||||
// snapshots _but_ not every single tick.
|
||||
if (!Application.isPlaying ||
|
||||
#if !UNITY_2020_3_OR_NEWER
|
||||
// Unity 2019 doesn't have Time.timeAsDouble yet
|
||||
AccurateInterval.Elapsed(NetworkTime.localTime, sendInterval, ref lastSendTime))
|
||||
#else
|
||||
AccurateInterval.Elapsed(Time.timeAsDouble, sendInterval, ref lastSendTime))
|
||||
#endif
|
||||
{
|
||||
Broadcast();
|
||||
}
|
||||
}
|
||||
|
||||
// update connections to flush out messages _after_ broadcast
|
||||
|
Loading…
Reference in New Issue
Block a user