@@ -63,6 +63,25 @@ protected override void OnCreatePlayerPrefab()
6363 base . OnCreatePlayerPrefab ( ) ;
6464 }
6565
66+ /// <summary>
67+ /// Bypassing this on v1.x as the deferred show message could be processed on the next
68+ /// frame from when the client registers having connected.
69+ /// </summary>
70+ protected override bool ShouldWaitForNewClientToConnect ( NetworkManager networkManager )
71+ {
72+ return false ;
73+ }
74+
75+ /// <summary>
76+ /// Validate that the player object is spawned on the client side.
77+ /// </summary>
78+ /// <returns></returns>
79+ private bool ClientSpawnedPlayer ( )
80+ {
81+ var playerObject = m_ClientNetworkManagers [ 0 ] . LocalClient . PlayerObject ;
82+ return playerObject != null && playerObject . IsSpawned && playerObject . IsOwner ;
83+ }
84+
6685 /// <summary>
6786 /// Tests the scenario where under a client-server network topology if a player prefab
6887 /// is spawned by the server with no observers but the player prefab itself has server
@@ -81,7 +100,17 @@ public IEnumerator NetworkShowOnSpawnTest([Values] PlayerSpawnStages spawnStage)
81100
82101 yield return CreateAndStartNewClient ( ) ;
83102
84- yield return new WaitForSeconds ( 0.25f ) ;
103+ // Wait for the new client to connect
104+ yield return WaitForClientsConnectedOrTimeOut ( ) ;
105+ AssertOnTimeout ( $ "Timed out waiting for client to connect!") ;
106+ OnNewClientStartedAndConnected ( m_ClientNetworkManagers [ 0 ] ) ;
107+
108+ // Wait for the new client to have spawned the player
109+ yield return WaitForConditionOrTimeOut ( ClientSpawnedPlayer ) ;
110+ AssertOnTimeout ( $ "Timed out waiting for client to spawn its player object!") ;
111+
112+ // Provide some time to assure there are no additional attempts to spawn the same instance
113+ yield return new WaitForSeconds ( 0.5f ) ;
85114
86115 NetcodeLogAssert . LogWasNotReceived ( LogType . Warning , new Regex ( "but it is already in the spawned list!" ) ) ;
87116 var client = GetNonAuthorityNetworkManager ( ) ;
0 commit comments