@@ -84,18 +84,33 @@ public IEnumerator TestTimeIntegrationTest(int targetFrameRate, uint tickRate)
84
84
85
85
var framesToRun = 3d / frameInterval ;
86
86
87
+ var waitForNextFrame = new WaitForFixedUpdate ( ) ;
88
+
87
89
for ( int i = 0 ; i < framesToRun ; i ++ )
88
90
{
89
- yield return null ;
90
- var capturedFrameRate = Time . captureFramerate ;
91
+ // Assure we wait for 1 frame to get the current frame time to check for low frame rates relative to expected frame rates
92
+ yield return waitForNextFrame ;
93
+
94
+ // Adjust the time tolerance based on slower than expected FPS
95
+ var currentFPS = 1.0f / Time . deltaTime ;
96
+ var fpsAdjustment = 1.0f ;
97
+ var currentAdjustment = additionalTimeTolerance ;
98
+ if ( currentFPS < targetFrameRate )
99
+ {
100
+ // Get the % slower and increase the time tolerance based on that %
101
+ var fpsDelta = targetFrameRate - currentFPS ;
102
+ fpsAdjustment = 1.0f / fpsDelta ;
103
+ currentAdjustment += additionalTimeTolerance * fpsAdjustment ;
104
+ }
105
+
91
106
UpdateTimeStates ( networkManagers ) ;
92
107
93
108
// compares whether client times have the correct offset to server
94
- m_ServerState . AssertCheckDifference ( m_Client1State , tickInterval , tickInterval , tickInterval * 2 + frameInterval * 2 + additionalTimeTolerance ) ;
95
- m_ServerState . AssertCheckDifference ( m_Client2State , 0.2 , 0.1 , tickInterval * 2 + frameInterval * 2 + additionalTimeTolerance ) ;
109
+ m_ServerState . AssertCheckDifference ( m_Client1State , tickInterval , tickInterval , tickInterval * 2 + frameInterval * 2 + currentAdjustment ) ;
110
+ m_ServerState . AssertCheckDifference ( m_Client2State , 0.2 , 0.1 , tickInterval * 2 + frameInterval * 2 + currentAdjustment ) ;
96
111
97
112
// compares the two client times, only difference should be based on buffering.
98
- m_Client1State . AssertCheckDifference ( m_Client2State , 0.2 - tickInterval , ( 0.1 - tickInterval ) , tickInterval * 2 + frameInterval * 2 + additionalTimeTolerance ) ;
113
+ m_Client1State . AssertCheckDifference ( m_Client2State , 0.2 - tickInterval , ( 0.1 - tickInterval ) , tickInterval * 2 + frameInterval * 2 + currentAdjustment ) ;
99
114
}
100
115
}
101
116
0 commit comments