host multiplayer game problems

Updated on December 23, 2017 in [A] Brackeys Courses
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on December 11, 2017

I can’t figure out why this script is not working and I have been trying for hours. Here it is: 

using UnityEngine;
using UnityEngine.Networking;

public class HostGame : MonoBehaviour {

[SerializeField]
private uint roomSize = 10;

private string password;

private string roomName;

private NetworkManager networkManager;

void Start()
{
networkManager = NetworkManager.singleton;
if (networkManager.matchMaker == null)
{
networkManager.StartMatchMaker();
}
}

public void SetRoomName(string _name)
{
roomName = _name;
}

public void SetRoomPassword(string _password)
{
password = _password;
}

public void CreateRoom()
{
if (roomName != “” && roomName != null)
{
networkManager.matchMaker.CreateMatch(roomName, roomSize, true, password, “”, “”, 0, 1, networkManager.OnMatchCreate);
}
}

}

When I assign the CreateRoom method to the host button it does not start the match and the console does not show a match request. I could really use some help. Thanks so much!

  • Liked by
Reply
0 on December 23, 2017

I am having the same problem :/ have you found a fix for this? thank you

  • Liked by
Reply
Cancel
0 on December 23, 2017

Did you try adding debug log messages to check where the problem occures?

 

  • Liked by
Reply
Cancel