Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Join Game multiplayer RoomListItem couldnt be found

DestroyerYTDestroyerYT Member
edited July 2020 in Brackeys' Tutorials

Hi i just watched the tutorial series on how to make a multiplayer game and im stuck at video 19 on the join game script,

thats the console errors, i also tried to copy the script from github but im getting the same error. im using unity version 2019.3.1 if somebody know how to fix it then please help me. Thanks

here is the script



using UnityEngine;

using UnityEngine.UI;

using System.Collections.Generic;

using UnityEngine.Networking;

using UnityEngine.Networking.Match;

using System.Collections;


public class JoinGame : MonoBehaviour

{


List<GameObject> roomList = new List<GameObject>();


[SerializeField]

private Text status;


[SerializeField]

private GameObject roomListItemPrefab;


[SerializeField]

private Transform roomListParent;

  [System.Obsolete]

  private NetworkManager networkManager;


  [System.Obsolete]

  void Start()

{

networkManager = NetworkManager.singleton;

if (networkManager.matchMaker == null)

{

networkManager.StartMatchMaker();

}


RefreshRoomList();

}


  [System.Obsolete]

  public void RefreshRoomList()

{

ClearRoomList();


if (networkManager.matchMaker == null)

{

networkManager.StartMatchMaker();

}


networkManager.matchMaker.ListMatches(0, 20, "", true, 0, 0, OnMatchList);

status.text = "Loading...";

}


  [System.Obsolete]

  public void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matchList)

{

status.text = "";


if (!success || matchList == null)

{

status.text = "Couldn't get room list.";

return;

}


foreach (MatchInfoSnapshot match in matchList)

{

GameObject _roomListItemGO = Instantiate(roomListItemPrefab);

_roomListItemGO.transform.SetParent(roomListParent);


RoomListItem _roomListItem = _roomListItemGO.GetComponent<RoomListItem>();

if (_roomListItem != null)

{

_roomListItem.Setup(match, JoinRoom);

}



// as well as setting up a callback function that will join the game.


roomList.Add(_roomListItemGO);

}


if (roomList.Count == 0)

{

status.text = "No rooms at the moment.";

}

}


void ClearRoomList()

{

for (int i = 0; i < roomList.Count; i++)

{

Destroy(roomList[i]);

}


roomList.Clear();

}


  [System.Obsolete]

  public void JoinRoom(MatchInfoSnapshot _match)

{

networkManager.matchMaker.JoinMatch(_match.networkId, "", "", "", 0, 0, networkManager.OnMatchJoined);

StartCoroutine(WaitForJoin());

}


  [System.Obsolete]

  IEnumerator WaitForJoin()

{

ClearRoomList();


int countdown = 10;

while (countdown > 0)

{

status.text = "JOINING... (" + countdown + ")";


yield return new WaitForSeconds(1);


countdown--;

}


// Failed to connect

status.text = "Failed to connect.";

yield return new WaitForSeconds(1);


MatchInfo matchInfo = networkManager.matchInfo;

if (matchInfo != null)

{

networkManager.matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, 0, networkManager.OnDropConnection);

networkManager.StopHost();

}


RefreshRoomList();


}


}


would be really helpfull if somebody could help me

Answers

Sign In or Register to comment.