@@ -270,6 +270,13 @@ public void Handle(ref NetworkContext context)
270270 // Only if scene management is disabled do we handle NetworkObject synchronization at this point
271271 if ( ! networkManager . NetworkConfig . EnableSceneManagement )
272272 {
273+ /// Mark the client being connected before running through the spawning synchronization so we
274+ /// can assure that if a user attempts to spawn something when an already spawned NetworkObject
275+ /// is spawned (during the initial synchronization just below) it will not error out complaining
276+ /// about the player not being connected.
277+ /// The check for this is done within <see cref="NetworkObject.SpawnInternal(bool, ulong, bool)"/>
278+ networkManager . IsConnectedClient = true ;
279+
273280 // DANGO-TODO: This is a temporary fix for no DA CMB scene event handling.
274281 // We will either use this same concept or provide some way for the CMB state plugin to handle it.
275282 if ( networkManager . DistributedAuthorityMode && networkManager . LocalClient . IsSessionOwner )
@@ -292,9 +299,6 @@ public void Handle(ref NetworkContext context)
292299 NetworkObject . AddSceneObject ( sceneObject , m_ReceivedSceneObjectData , networkManager ) ;
293300 }
294301
295- // Mark the client being connected
296- networkManager . IsConnectedClient = true ;
297-
298302 if ( networkManager . AutoSpawnPlayerPrefabClientSide )
299303 {
300304 networkManager . ConnectionManager . CreateAndSpawnPlayer ( OwnerClientId ) ;
@@ -315,14 +319,14 @@ public void Handle(ref NetworkContext context)
315319 if ( networkManager . DistributedAuthorityMode && networkManager . CMBServiceConnection && networkManager . LocalClient . IsSessionOwner && networkManager . NetworkConfig . EnableSceneManagement )
316320 {
317321 // Mark the client being connected
318- networkManager . IsConnectedClient = true ;
322+ networkManager . IsConnectedClient = networkManager . ConnectionManager . LocalClient . IsApproved ;
319323
320324 networkManager . SceneManager . IsRestoringSession = GetIsSessionRestor ( ) ;
321325
322326 if ( ! networkManager . SceneManager . IsRestoringSession )
323327 {
324328 // Synchronize the service with the initial session owner's loaded scenes and spawned objects
325- networkManager . SceneManager . SynchronizeNetworkObjects ( NetworkManager . ServerClientId ) ;
329+ networkManager . SceneManager . SynchronizeNetworkObjects ( NetworkManager . ServerClientId , true ) ;
326330
327331 // Spawn any in-scene placed NetworkObjects
328332 networkManager . SpawnManager . ServerSpawnSceneObjectsOnStartSweep ( ) ;
@@ -334,7 +338,7 @@ public void Handle(ref NetworkContext context)
334338 }
335339
336340 // Synchronize the service with the initial session owner's loaded scenes and spawned objects
337- networkManager . SceneManager . SynchronizeNetworkObjects ( NetworkManager . ServerClientId ) ;
341+ networkManager . SceneManager . SynchronizeNetworkObjects ( NetworkManager . ServerClientId , true ) ;
338342
339343 // With scene management enabled and since the session owner doesn't send a Synchronize scene event synchronize itself,
340344 // we need to notify the session owner that everything should be synchronized/spawned at this time.
0 commit comments