mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: NetworkClient.sendRate is now coupled to NetworkServer.sendRate in order to avoid snapshot interpolation errors where server & client may be on different send rates, components use the wrong rate to send vs. interpolate, etc.
This commit is contained in:
parent
464bd365fe
commit
1176494587
@ -20,12 +20,16 @@ public enum ConnectState
|
||||
/// <summary>NetworkClient with connection to server.</summary>
|
||||
public static partial class NetworkClient
|
||||
{
|
||||
// send time snapshot every sendInterval.
|
||||
// client may run at very high update rate for rendering.
|
||||
// we don't want to send a time snapshot 120 times per second though.
|
||||
// -> components are only synced when dirty though
|
||||
// -> Timesnapshots are sent every sendRate
|
||||
public static int sendRate = 30;
|
||||
// time & value snapshot interpolation are separate.
|
||||
// -> time is interpolated globally on NetworkClient / NetworkConnection
|
||||
// -> value is interpolated per-component, i.e. NetworkTransform.
|
||||
// however, both need to be on the same send interval.
|
||||
//
|
||||
// additionally, server & client need to use the same send interval.
|
||||
// otherwise it's too easy to accidentally cause interpolation issues if
|
||||
// a component sends with client.interval but interpolates with
|
||||
// server.interval, etc.
|
||||
public static int sendRate => NetworkServer.sendRate;
|
||||
public static float sendInterval => sendRate < int.MaxValue ? 1f / sendRate : 0; // for 30 Hz, that's 33ms
|
||||
static double lastSendTime;
|
||||
|
||||
|
@ -49,9 +49,10 @@ public class NetworkManager : MonoBehaviour
|
||||
[Obsolete("NetworkManager.serverTickInterval was moved to NetworkServer.tickInterval for consistency.")]
|
||||
public float serverTickInterval => NetworkServer.tickInterval;
|
||||
|
||||
/// <summary>Server Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.</summary>
|
||||
[Tooltip("Client broadcasts 'sendRate' times per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.")]
|
||||
public int clientSendRate = 30; // 33 ms
|
||||
// client send rate follows server send rate to avoid errors for now
|
||||
/// <summary>Client Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.</summary>
|
||||
// [Tooltip("Client broadcasts 'sendRate' times per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.")]
|
||||
// public int clientSendRate = 30; // 33 ms
|
||||
|
||||
/// <summary>Automatically switch to this scene upon going offline (on start / on disconnect / on shutdown).</summary>
|
||||
[Header("Scene Management")]
|
||||
@ -328,7 +329,7 @@ void SetupClient()
|
||||
authenticator.OnClientAuthenticated.AddListener(OnClientAuthenticated);
|
||||
}
|
||||
|
||||
NetworkClient.sendRate = clientSendRate;
|
||||
// NetworkClient.sendRate = clientSendRate;
|
||||
}
|
||||
|
||||
/// <summary>Starts the client, connects it to the server with networkAddress.</summary>
|
||||
|
Loading…
Reference in New Issue
Block a user