Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ajaybhojani · May 25, 2016 at 07:17 AM · networkingmultiplayerphotonrealtime

Photon multiplayer room make disappear in lobby when room is getting full

Hi all, I am making realtime multiplayer game and using photon realtime networking SDK. want to Provide on options like for matchmaking rooms.

1) Room#1 - with two maximum player capacity 2)Room#2 - with four maximum player capacity

If in these case if Room#1 player count (getting full) then this room name should not be visible in lobby. same as for 4 player Room#2, it should getting visible false. these room should not visible to other connected player in lobby. How can it is possible ? which photon function should i have call ? and when call ?

Thanks in advance

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fillefilip8 · May 25, 2016 at 09:48 AM 0
Share

When the game starts u can set maybe like a custom properties to the room. And only show the rooms that has "visable" = true on the custom properties.

avatar image AlucardJay fillefilip8 · May 25, 2016 at 11:37 AM 0
Share

The OP is asking about when a room is populated, not when it is created. Also, the reason for the visible boolean is for not displaying invisible rooms when polling GetRoomList() for the RoomInfo.

avatar image ajaybhojani AlucardJay · May 25, 2016 at 11:43 AM 0
Share

ok thanks!!!

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by AlucardJay · May 25, 2016 at 08:50 AM

To hide a room from the lobby :

 PhotonNetwork.room.visible = false;

To close a room :

 PhotonNetwork.room.open = false;

Typically you could handle toggling these values in the callbacks OnJoinedRoom() and OnPhotonPlayerConnected( PhotonPlayer other )

e.g. the master client keeps track of when someone joins the room. If the maximum number of players is in the room, then set visible and open to false. You really only need to use visible, however open is useful if the person knows the room name (even if it is not listed in the lobby).

OnPhotonPlayerConnected( PhotonPlayer other ) is not seen by the person joining the room, only all others in the room. So the master client would use OnJoinRoom. Example untested code :

 int maxNumPlayers = 2; // 2,4, whatever value you set in CreateRoom()
 int playerCount = 0;
 
 void OnJoinedRoom()
 {
     // master client joined, set playerCount to 1
     if ( PhotonNetwork.isMasterClient ) 
     {
         playerCount = 1;
     }
 }
 
 void OnPhotonPlayerConnected( PhotonPlayer other ) // not seen if you're the player connecting
 {
     // player joined, master client then increments playerCount
     if ( PhotonNetwork.isMasterClient ) 
     {
         playerCount ++;
         
         // hide and close the room if it is full
         if ( playerCount == maxNumPlayers )
         {
             PhotonNetwork.room.visible = false;
             PhotonNetwork.room.open = false;
         }
     }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

80 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

how to host unity multiplayer game in my vps? 0 Answers

make disappear room which has maximum player connected 1 Answer

Unity Multiplayer (Mirror) - Problem in syncing game object's variables across all clients. [Trying to send command for object without authority] 0 Answers

Re altimeMultiplayer Module 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges