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.transform.SetParent(this.transform);
deck.GetComponent<Deck>().currentRoom.Value = i;
deck.GetComponent<NetworkObject>().Spawn(true);
}
}
}
}
}
Am I doing something wrong here?