Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 samz · Jan 25, 2015 at 01:48 AM · multiplayerphotononlinelobby

Unity Photon - Multiple Lobbies

I might be asking the wrong question hence why I still have not found any answers yet. Basically my game model is of 5 levels. Each level has lots of players who are currently on that level. i.e. Level 3 players will be in the Level 3 group to have 1:1 matches with other level 3 players.

My Photon idea: I was thinking of creating 5 lobbies for each of the levels. And then for the 1:1 matches have the player automatically joined to a random player within their lobby. Am I on the right track or have I understood Photo completely wrong?

If this idea is correct then below is my current code:

 void Start () 
     {    
         PhotonNetwork.ConnectUsingSettings ("0.1");
     }
 
     // <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 
     public void Connect()
     {
         PhotonNetwork.autoJoinLobby = false; 
     }
 
     // <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 
     void OnConnectedToMaster()
     {
         int index = PlayerPrefs.GetInt("PlayerLevel") - 1;
 
         TypedLobby newLobby = new TypedLobby(index.ToString(), LobbyType.SqlLobby);
         PhotonNetwork.JoinLobby(newLobby);
     }
 
     // <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 
     void OnJoinedLobby()
     {
         PhotonNetwork.JoinRandomRoom ();
     }
 
     // <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
     
     void OnPhotonRandomJoinFailed()
     {
         PhotonNetwork.CreateRoom(null);
     }
 
     // <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 
     private PhotonView myPhotonView;
     void OnJoinedRoom()
     {
         GameObject monster = PhotonNetwork.Instantiate("monsterprefab", Vector3.zero, Quaternion.identity, 0);
         monster.GetComponent<myThirdPersonController>().isControllable = true;
         myPhotonView = monster.GetComponent<PhotonView>();
     }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by tobiass · Feb 02, 2015 at 12:36 PM

The idea is correct. I didn't check your code in detail but it looks ok. In all cases, you join a specific lobby per level. When joined into a specific lobby, all join/create calls will refer to this lobby. The room is invisible in other lobbies.

You don't have to use a SQLLobby. If you don't need the more complex filtering it offers, simply use a default lobby type.

If you wanted to, you can also use JoinRandomRoom and CreateRoom overloads which have a TypedLobby parameter. So you don't even have to join a lobby to create or find rooms in it. You just pass that lobby as parameter.

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

20 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

Related Questions

Unity3D: Photon syncing physics events 0 Answers

increase unet hosts 0 Answers

PUN Update countOfPlayersOnMaster to all clients? 1 Answer

Photon variable synchronization 1 Answer

Unity3D Multiplayer with Photon 1 Answer


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