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.

Unity Multiplayer [PHOTON]Wont join room

Discussion in 'Multiplayer' started by Moddwyn, Apr 6, 2017.

  1. Moddwyn

    Moddwyn

    Joined:
    Jan 27, 2016
    Posts:
    49
    https://pastebin.com/dj5ztAM7 At line 63, I check if i'm in a room, which I am. If I am in a room, I will leave that room in line 65. Then at line 70, I check if i'm not in a room which i'm not anymore because I left the room at line 65. The problem is, it wont return true/it won't debug line 71. Why won't it return true if I left the room in line 65?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,991
    Joining and leaving rooms are "network actions", if you will. As the server needs to do something for you, it will take a moment to get from state to state.
    You should base your workflow on the callbacks PUN provides. When you call Join*(), wait for OnJoinedRoom(). When you call Leave(), PUN will return to the Master Server and OnJoinedLobby() or OnConnectedToMaster() are called when PUN is ready.

    All callbacks are in a PunBehaviour for your convenience:
    http://doc-api.exitgames.com/en/pun/current/class_photon_1_1_pun_behaviour.html

    Check out the Basics Tutorial and other docs, too:
    http://doc.photonengine.com/en-us/pun/current/tutorials/pun-basics-tutorial/intro
     
    Moddwyn likes this.
  3. Moddwyn

    Moddwyn

    Joined:
    Jan 27, 2016
    Posts:
    49
    If you're in a room, and i joined another room, that would put me in the new room. So do i need to leave room to switch rooms?
     
  4. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    What a question lol, Of course.