Spawn() and late joiners

So as far as I understood from the documentation, the function Spawn should make that all late joiners also instantiate the object. But currently I can only make it work for players already connected to the server.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;

public class PrepareGameplay_Server : MonoBehaviour
    [HideInInspector] public int quantityOfRooms;
    [HideInInspector] public int decksPerRoom;
    [SerializeField] GameObject deckPrefab;

    void Start()
        if (NetworkManager.Singleton.IsServer)
            for (int i = 0; i < quantityOfRooms; i++)
                for (int j = 0; j < decksPerRoom; j++)
                    GameObject deck = Instantiate(deckPrefab);
                    deck.GetComponent<Deck>().currentRoom.Value = i;

Am I doing something wrong here?


What jumps out at me is line 21 where you're modifying the parent of the GameObject prior to spawning the NetworkObject over the network.

Modifications of a NetworkObject's parent should always go through the NetworkObject.TrySetParent API as detailed here: You would want to ensure that the GameObject that you're parenting the deck to is also a NetworkObject, and that you perform this operation after spawning the NetworkObject.

Assuming the deck NetworkObject is registered under your NetworkManager's list of NetworkPrefabs, the rest should still work, and Netcode will automatically synchronize the server's NetworkObjects to the late-joining client.

Are there any warnings or logs produced on the late-joining client you're able to share? I hope that helps!