Skip to content

Commit 4613300

Browse files
committed
Merge branch 'feature/bad-network-condition-warning' of https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop into feature/bad-network-condition-warning
2 parents 2311d07 + 6b51417 commit 4613300

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Assets/BossRoom/Scripts/Infrastructure/NetworkStats.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public ExponentialMovingAverageCalculator(float average)
4242
const float k_PingIntervalSeconds = 0.1f;
4343
const float k_MaxWindowSize = k_MaxWindowSizeSeconds / k_PingIntervalSeconds;
4444

45+
// Some games are less sensitive to latency than others. For fast-paced games, latency above 100ms becomes a challenge for players while for others 500ms is fine. It's up to you to establish those thresholds.
4546
const float k_StrugglingNetworkConditionsRTTThreshold = 130;
4647
const float k_BadNetworkConditionsRTTThreshold = 200;
4748

@@ -146,6 +147,7 @@ void FixedUpdate()
146147
if (m_TextBadNetworkConditions != null)
147148
{
148149
// Right now, we only base this warning on UTP's RTT metric, but in the future we could watch for packet loss as well, or other metrics.
150+
// This could be a simple icon instead of doing heavy string manipulations.
149151
m_TextBadNetworkConditions.text = m_UtpRTT.Average > k_BadNetworkConditionsRTTThreshold ? "Bad Network Conditions Detected!" : "";
150152
var color = Color.red;
151153
color.a = Mathf.PingPong(Time.time, 1f);

0 commit comments

Comments
 (0)