Skip to content

Commit 376ec61

Browse files
test update
This validates the issue with the more recent updates that revealed the network state only having the most recent deltas and not the full transform state. This resulted in various "seemingly" random late join transform synchronization issues (specifically the scale that is not being synchronized when spawning NetworkObjects).
1 parent 45e80cb commit 376ec61

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,12 @@ private IEnumerator WaitForNextTick()
387387
// The number of iterations to change position, rotation, and scale for NetworkTransformMultipleChangesOverTime
388388
private const int k_PositionRotationScaleIterations = 8;
389389

390+
protected override void OnNewClientCreated(NetworkManager networkManager)
391+
{
392+
networkManager.NetworkConfig.NetworkPrefabs = m_ServerNetworkManager.NetworkConfig.NetworkPrefabs;
393+
base.OnNewClientCreated(networkManager);
394+
}
395+
390396
/// <summary>
391397
/// This validates that multiple changes can occur within the same tick or over
392398
/// several ticks while still keeping non-authoritative instances synchronized.
@@ -422,6 +428,23 @@ public IEnumerator NetworkTransformMultipleChangesOverTime([Values] TransformSpa
422428
yield return WaitForPositionRotationAndScaleToMatch(4);
423429
}
424430

431+
// Check scale for all player instances when a client late joins
432+
// NOTE: This validates the use of the spawned object's transform values as opposed to the replicated state (which now is only the last deltas)
433+
yield return CreateAndStartNewClient();
434+
var newClientNetworkManager = m_ClientNetworkManagers[NumberOfClients];
435+
foreach (var playerRelativeEntry in m_PlayerNetworkObjects)
436+
{
437+
foreach (var playerInstanceEntry in playerRelativeEntry.Value)
438+
{
439+
var playerInstance = playerInstanceEntry.Value;
440+
if (newClientNetworkManager.LocalClientId == playerInstance.OwnerClientId)
441+
{
442+
Assert.IsTrue(Aproximately(m_PlayerPrefab.transform.localScale, playerInstance.transform.localScale), $"{playerInstance.name}'s cloned instance's scale does not match original scale!\n" +
443+
$"[ClientId-{playerRelativeEntry.Key} Relative] Player-{playerInstance.OwnerClientId}'s LocalScale ({playerInstance.transform.localScale}) vs Target Scale ({m_PlayerPrefab.transform.localScale})");
444+
}
445+
}
446+
}
447+
425448
// Repeat this in the opposite direction
426449
for (int i = -1; i > -1 * (k_PositionRotationScaleIterations + 1); i--)
427450
{

0 commit comments

Comments
 (0)