简体   繁体   中英

Unity and Photon Networking - Wait for other players

I am currently trying to integrate a multiplayer option into my unity game with photon networking. However, I do have some questions: I created the GUI with Unity's new GUI System. I am not using OnGui at all. What I am trying to do is let a user create a room. After he/she created a room, the user will be redirected in some sort of a "waiting room" in which he waits for other players to join. How is something like that done? All the tutorials just basically cover up how to jump right into a game. But what I want to do is get them together inside this "waiting room" and start the game (by switching the scene) once max players is reached.

I am able to create a room in the editor. I also made a build so I can test it out on my laptop. I tried to show all rooms inside an update(). But it won't show any rooms at all although I've created one.

I think I'm missing out on something, any tips?

Thanks!

What prevents you from using Photon lobby system? Player created the room sits in the room and waits while other players in the lobby choose which room join.

如果您不能使用大厅系统,则只需遍历光子播放器的数量,看看其中是否只有一个。

if (PhotonNetwork.playerList.Count == 1) Teleport_To_A_Waiting_Zone();

Photon doesn't have a "waiting room" or any sort of pre-room lobby.

When not in a Room: - You can get the list of rooms, and call create/join.

Once you are in a Room: - Well.. you're in the room :)

I faked a "lobby" for one of my games by using a "custom property" on the room", when the room is created you can set a property such as ["roomState"] = "notready"

Then when all the players are in the room, change the state.

Your main loop could check the property and if it's not set, then just wait or exit the loop, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM