Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Join Or Create Room Button Doesn't Work

Discussion in 'Multiplayer' started by DincaAlin, Jun 14, 2015.

  1. DincaAlin

    DincaAlin

    Joined:
    Apr 8, 2015
    Posts:
    13
    Hi everyone! I have followed the Mike Geig tutorial about creating Merry Fragmas multiplayer game and at 3rd part I find a problem. I have followed exactly the instructions, but when i need to click on "Join or create room" button, nothing happens. I have read again my NetworkManager script, but I don't find any mistakes and I don't have any errors. CAN SOMEONE HELP ME TO FIX THIS?
    IN THE PHOTOS:
    1ST PHOTO BEFORE CLICK ON THE GREEN BUTTON.
    2ND PHOTO AFTER CLICKED ON THE GREEN BUTTON. Fără titlu.gif Fără titlu.gif
     
  2. DincaAlin

    DincaAlin

    Joined:
    Apr 8, 2015
    Posts:
    13
    Here is the NetworkManager script:


    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;

    public class NetworkManager : MonoBehaviour {

    [@SerializeField] Text connectionText;
    [@SerializeField] Transform[] spawnPoints;
    [@SerializeField] Camera sceneCamera;

    [@SerializeField] GameObject serverWindow;
    [@SerializeField] InputField username;
    [@SerializeField] InputField roomName;
    [@SerializeField] InputField roomList;

    public GameObject player;

    void Start () {

    PhotonNetwork.logLevel = PhotonLogLevel.Full;
    PhotonNetwork.ConnectUsingSettings ("0.9112");
    StartCoroutine ("UpdateConnectionString");
    }

    IEnumerator UpdateConnectionString ()
    {
    while (true)
    {
    connectionText.text = PhotonNetwork.connectionStateDetailed.ToString ();
    yield return null;
    }
    }

    void OnJoinedLobby ()
    {
    serverWindow.SetActive (true);
    }

    public void JoinRoom()
    {
    RoomOptions ro = new RoomOptions () {isVisible = true, maxPlayers = 10};
    PhotonNetwork.JoinOrCreateRoom ("Mike", ro, TypedLobby.Default);
    }

    void OnJoinedRoom ()
    {
    StopCoroutine ("UpdateConnectionString");
    connectionText.text = "";
    StartSpawnProcess (0f);
    }

    void StartSpawnProcess (float respawnTime)
    {
    sceneCamera.enabled = true;
    StartCoroutine ("SpawnPlayer", respawnTime);
    }

    IEnumerator SpawnPlayer(float respawnTime)
    {
    yield return new WaitForSeconds(respawnTime);

    int index = Random.Range (0, spawnPoints.Length);
    player = PhotonNetwork.Instantiate ("FPSPlayer", spawnPoints [index].position, spawnPoints [index].rotation, 0);

    player.GetComponent<PlayerNetworkMover> ().RespawnMe += StartSpawnProcess;
    sceneCamera.enabled = false;
    }
    }
     
  3. Necromantic

    Necromantic

    Joined:
    Feb 11, 2013
    Posts:
    116
    Hey, first I thought this was related to the problem I had with the Cloud ID but then I saw that you are using Photon. Shouldn't the Unity Multiplayer Prefix be removed? As I understand it's exclusively for the new Unity 5.1 Networking features.
    It might get people confused (as it did me initially).
     
  4. LovattoStudio

    LovattoStudio

    Joined:
    Feb 11, 2015
    Posts:
    15
    You receive any debug warning or error in console when join in room / press button?
     
    tobiass likes this.
  5. DincaAlin

    DincaAlin

    Joined:
    Apr 8, 2015
    Posts:
    13
    No, I don't have any debug warnings or error in console. I think is a bug from here:
    I draged the NetworkManager there and I add to JoinRoom when I click on the button, but it don't work... Maybe the button need's a special script?
    red.gif
     
    Last edited: Jun 15, 2015
  6. DincaAlin

    DincaAlin

    Joined:
    Apr 8, 2015
    Posts:
    13
    I don't know at you reffer when you say "Unity Multiplayer Prefix". Can explaine me more about it, please?
     
  7. Mogitu

    Mogitu

    Joined:
    Nov 13, 2013
    Posts:
    40
    You are using Photon, and not the new Unity (UNET) networking system. Threads that don't use UNET should not have the "Unity Multiplayer" prefix in the title, like your did.
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    There should be something in the log / console when things fail Are you connected?
    In doubt, make sure JoinRoom gets called by your button by adding a Debug.Log in there.
     
  9. DincaAlin

    DincaAlin

    Joined:
    Apr 8, 2015
    Posts:
    13
    I have in console these logs (are the last 18 logs): log.gif
     
  10. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    Those are event logs and not errors. There are also a few operations in-between and those show you switched back to the master server. No error.
    Look out for a ReturnCode != 0, if you can't make out the problem.
     
  11. DincaAlin

    DincaAlin

    Joined:
    Apr 8, 2015
    Posts:
    13
    I FIXED THAT PROBLEM! I JUST ADD IN HIERARCHY AN EVENT SYSTEM ANT IT WORK.
     
    tobiass likes this.