Search Unity

Unity Multiplayer [PHOTON]Wont join room

Discussion in 'Connected Games' started by Moddwyn16MC, Apr 6, 2017.

  1. Moddwyn16MC

    Moddwyn16MC

    Joined:
    Jan 27, 2016
    Posts:
    44
    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,253
    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
     
    Moddwyn16MC likes this.
  3. Moddwyn16MC

    Moddwyn16MC

    Joined:
    Jan 27, 2016
    Posts:
    44
    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.
     
unityunity