简体   繁体   English

Unity和光子网络-等待其他玩家

[英]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. 但是,我确实有一些问题:我使用Unity的新GUI系统创建了GUI。 I am not using OnGui at all. 我根本没有使用OnGui。 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(). 我试图在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? 是什么使您无法使用Photon大厅系统? 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. Photon没有“候诊室”或任何类型的术前大厅。

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" 我通过在房间上使用“自定义属性”为我的其中一个游戏伪造了一个“大厅”,创建房间时,您可以设置一个属性,例如[“ 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. 您的主循环可以检查该属性,如果未设置该属性,则只需等待或退出循环等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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