Hi,

I'm Litkey.

What me and my teammates did for fast few weeks:

- Setup Multiplayer environment (Netcode for GameObjects (Unity Gaming Services))

- Made lobby and relay server

- Synced VolleyBall for server and client environment

- Playtested up to 4 vs 4 environment

- Made Menu Scene

Once you Create the room, the Join Code will display on top left side of your screen.

HeartBeat: to not lost connection when room is made

private static IEnumerator HeartbeatLobbyCoroutine(string lobbyID, float waitTimeSeconds)
    {
        var delay = new WaitForSecondsRealtime(waitTimeSeconds);
        while (true)
        {
            Lobbies.Instance.SendHeartbeatPingAsync(lobbyID);
            yield return delay;
        }
    }

- Creates Lobby: makes allocation by the number of max players that can join to Unity's RelayService and get the join code based on the given allocation id that is returned

// Lobby will automatically shut down when there is inactivity for more than 30 secs
    public async Task<Lobby> CreateLobby()
    {
        try 
        {
            uiManager.GetComponent<UIManager>().SetGameActive(true);

            // create a relay allocation and generate a join code to share with the lobby
            var a = await RelayService.Instance.CreateAllocationAsync(maxPlayers);
            _joinCodeOutput.text = await RelayService.Instance.GetJoinCodeAsync(a.AllocationId);

            // Create a lobby, adding the relay join code to the lobby data
            var options = new CreateLobbyOptions
            {
                Data = new Dictionary<string, DataObject> { { JoinCodeKey, new DataObject(DataObject.VisibilityOptions.Public, _joinCodeOutput.text) } }
            };
            var lobby = await Lobbies.Instance.CreateLobbyAsync("Lobby Name 1", maxPlayers, options);

            // Send a heartbeat every 15 seconds to keep room alive
            // StartCoroutine(HeartbeatLobbyCoroutine(lobby.Id, 15));

            // Set the game room to use the relay allocation
            _transport.SetHostRelayData(a.RelayServer.IpV4, (ushort)a.RelayServer.Port, a.AllocationIdBytes, a.Key, a.ConnectionData);

            // Start the room. I'm doing this immediately, but maybe you wait for the lobby fto fill up
            NetworkManager.Singleton.StartHost();
            return lobby;
        } 
        catch(Exception e)
        {
            Debug.LogFormat("Failed creating a lobby: {0}", e);
            return null;
        }
    }

TODO:

- Make list of public lobbies and make player join on double click or join button

- Design UI for list of lobbies

복사했습니다!