-3
\$\begingroup\$

I get the following error

“NullReferenceException: Object reference not set to an instance of an object”

I have updated it by adding extra arguments but I still get that issue. Below is my code, the issue is on the final line.

using UnityEngine;
using UnityEngine.Networking;

public class Host : MonoBehaviour {

[SerializeField]
private uint roomSize = 8;
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 CreateRoom() {
    if (roomName != “” && roomName != null) {
        Debug.Log (“Creating Room: ” + roomName + ” with room for ” + roomSize + ” players.”);
        networkManager.matchMaker.CreateMatch(roomName, roomSize, true, “”, “”, “”, 0, 0, networkManager.OnMatchCreate);
    }
}
}
\$\endgroup\$
2
\$\begingroup\$

Your start-method isn't executed because you spelled it wrong. It's void Start (), not void start().

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.