Hello,
I´m new to Unity Multiplayer section and trying to create a simple multiplayer game while using Unity Lobby. I´ve managed to create a lobby and join it with another instance of my application using the provided join code. Now when I try to query for existing lobbys to show them to the user as options no matter what I try to do the query yields 0 results. Is there anything I might be missing ?
Here is how I create my lobby:
public static async Task CreateLobby(LobbyConfig config)
{
transport = Object.FindObjectOfType<UnityTransport>();
var alloc = await RelayService.Instance.CreateAllocationAsync(config.maxPlayerAmount);
var joinCode = await RelayService.Instance.GetJoinCodeAsync(alloc.AllocationId);
var lobbyOptions = new CreateLobbyOptions
{
Data = new Dictionary<string, DataObject>
{
{ Constants.JoinCode, new DataObject(DataObject.VisibilityOptions.Member,joinCode)},
{ Constants.LobbyName, new DataObject(DataObject.VisibilityOptions.Public,config.lobbyName)}
}
};
lobbyOptions.IsPrivate = false;
currentLobby = await Lobbies.Instance.CreateLobbyAsync(config.lobbyName,config.maxPlayerAmount,lobbyOptions);
transport.SetHostRelayData(alloc.RelayServer.IpV4, (ushort)alloc.RelayServer.Port,alloc.AllocationIdBytes,alloc.Key,alloc.ConnectionData);
Debug.Log("Lobbyname: " + currentLobby.Name);
Debug.Log("LobbyCode: " + currentLobby.LobbyCode);
Debug.Log("Private: "+ currentLobby.IsPrivate);
Debug.Log("Slots: " + (currentLobby.MaxPlayers - currentLobby.AvailableSlots)+"/" + currentLobby.MaxPlayers);
PingCurrentLobby(); //Heartbeat
RefreshLobby();
}
and here how I try to find it:
public static async Task<List<Lobby>> SearchLobbies()
{
var foundLobbies = await Lobbies.Instance.QueryLobbiesAsync();
Debug.Log("LobbyCount: " + foundLobbies.Results.Count);
return foundLobbies.Results;
}
Thanks in advance!