@@ -148,6 +148,10 @@ public IEnumerator NetworkTransformParentingLocalSpaceOffsetTests([Values] Trans
148
148
yield return null ;
149
149
}
150
150
151
+ /// <summary>
152
+ /// Moves and rotates the authority side with a single frame between
153
+ /// both actions in order to
154
+ /// </summary>
151
155
private IEnumerator MoveAndRotateAuthority ( Vector3 position , Vector3 rotation )
152
156
{
153
157
m_AuthoritativeTransform . transform . position = position ;
@@ -179,30 +183,40 @@ private IEnumerator WaitForPositionAndRotationToMatch(int ticksToWait)
179
183
$ "Authority ({ m_AuthoritativeTransform . transform . rotation . eulerAngles } ) Non-Authority ({ m_NonAuthoritativeTransform . transform . rotation . eulerAngles } )") ;
180
184
}
181
185
182
- [ UnityTest ]
183
- public IEnumerator NetworkTransformMultipleChangesOverTime ( [ Values ] TransformSpace testLocalTransform , [ Values ] OverrideState overideState )
186
+ private IEnumerator WaitForNextTick ( )
184
187
{
185
- var overrideUpdate = overideState == OverrideState . CommitToTransform ;
186
- m_AuthoritativeTransform . InLocalSpace = testLocalTransform == TransformSpace . Local ;
187
-
188
- // Wait for tick to change (so we start close to the beginning the next tick)
189
188
var currentTick = m_AuthoritativeTransform . NetworkManager . LocalTime . Tick ;
190
189
while ( m_AuthoritativeTransform . NetworkManager . LocalTime . Tick == currentTick )
191
190
{
192
191
yield return null ;
193
192
}
193
+ }
194
+
195
+ [ UnityTest ]
196
+ public IEnumerator NetworkTransformMultipleChangesOverTime ( [ Values ] TransformSpace testLocalTransform , [ Values ] OverrideState overideState )
197
+ {
198
+ var overrideUpdate = overideState == OverrideState . CommitToTransform ;
199
+ m_AuthoritativeTransform . InLocalSpace = testLocalTransform == TransformSpace . Local ;
194
200
195
201
var positionStart = new Vector3 ( 1.0f , 0.5f , 2.0f ) ;
196
202
var rotationStart = new Vector3 ( 0.0f , 45.0f , 0.0f ) ;
197
203
var position = positionStart ;
198
204
var rotation = rotationStart ;
205
+
199
206
// Move and rotate within the same tick, validate the non-authoritative instance updates
200
207
// to each set of changes. Repeat several times.
201
208
for ( int i = 1 ; i < m_PositionRotationIterations + 1 ; i ++ )
202
209
{
203
210
position = positionStart * i ;
204
211
rotation = rotationStart * i ;
212
+ // Wait for tick to change so we cam start close to the beginning the next tick in order
213
+ // to apply both deltas within the same tick period.
214
+ yield return WaitForNextTick ( ) ;
215
+
216
+ // Apply deltas
205
217
MoveAndRotateAuthority ( position , rotation ) ;
218
+
219
+ // Wait for deltas to synchronize on non-authoritative side
206
220
yield return WaitForPositionAndRotationToMatch ( 4 ) ;
207
221
}
208
222
@@ -211,23 +225,35 @@ public IEnumerator NetworkTransformMultipleChangesOverTime([Values] TransformSpa
211
225
{
212
226
position = positionStart * i ;
213
227
rotation = rotationStart * i ;
228
+ // Wait for tick to change so we cam start close to the beginning the next tick in order
229
+ // to apply both deltas within the same tick period.
230
+ yield return WaitForNextTick ( ) ;
231
+
214
232
MoveAndRotateAuthority ( position , rotation ) ;
215
233
yield return WaitForPositionAndRotationToMatch ( 4 ) ;
216
234
}
217
235
236
+ // Wait for tick to change so we cam start close to the beginning the next tick in order
237
+ // to apply as many deltas within the same tick period as we can (if not all)
238
+ yield return WaitForNextTick ( ) ;
239
+
218
240
// Move and rotate within the same tick several times, then validate the non-authoritative
219
241
// instance updates to the authoritative instance's final position and rotation.
220
242
for ( int i = 1 ; i < m_PositionRotationIterations + 1 ; i ++ )
221
243
{
222
244
position = positionStart * i ;
223
245
rotation = rotationStart * i ;
224
- MoveAndRotateAuthority ( position , rotation ) ;
225
246
247
+ MoveAndRotateAuthority ( position , rotation ) ;
226
248
}
227
249
228
250
yield return WaitForPositionAndRotationToMatch ( 1 ) ;
229
251
230
- // Repeat this in the opposite direction
252
+ // Wait for tick to change so we cam start close to the beginning the next tick in order
253
+ // to apply as many deltas within the same tick period as we can (if not all)
254
+ yield return WaitForNextTick ( ) ;
255
+
256
+ // Repeat this in the opposite direction and rotation
231
257
for ( int i = - 1 ; i > - 1 * ( m_PositionRotationIterations + 1 ) ; i -- )
232
258
{
233
259
position = positionStart * i ;
@@ -237,8 +263,6 @@ public IEnumerator NetworkTransformMultipleChangesOverTime([Values] TransformSpa
237
263
yield return WaitForPositionAndRotationToMatch ( 1 ) ;
238
264
}
239
265
240
-
241
-
242
266
/// <summary>
243
267
/// Tests changing all axial values one at a time.
244
268
/// These tests are performed:
0 commit comments