如何使用PUN Unity3D将玩家重新加入房间?

编程入门 行业动态 更新时间:2024-10-28 16:22:01
本文介绍了如何使用PUN Unity3D将玩家重新加入房间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用PUN构建多人游戏,一个房间中的两个玩家将彼此玩耍. 在播放时,如果播放器的网络看起来非常慢,则他/她会自动从Photon服务器断开连接. 我想给一个等待时间,以响应断开连接的玩家,同时他可以再次加入会议室并继续他的游戏.

I am building a multiplayer game using PUN where two player in a room will play with each other. While playing if network seems very slow of a player, he/she automatically disconnected from Photon server. I want to give a waiting time to respond the disconnected player and meanwhile he can again join the room and continue his game.

我该怎么做? 任何帮助都将受到高度赞赏. TIA

How can I do this? Any kind of help is highly appreciated. TIA

推荐答案

PUN不支持基于Phtoon Turnbased的重新加入(保留了演员编号和玩家状态). 因此,您需要处理断开连接事件,然后以新播放器的身份重新连接,并使用断开连接的播放器的状态更新此播放器状态(有时可能很棘手).您可能会发现更容易将所有状态存储在房间属性中,并通过名称或userId在其中引用玩家.

PUN does not support rejoin as Phtoon Turnbased does (with actor number and player state preserved). So you need to handle disconnection event and reconnect again as a new player and update this player state with the state of disconnected player (that may be tricky sometimes). You may find easier to store all state in room properties and reference players there via name or userId.

更多推荐

如何使用PUN Unity3D将玩家重新加入房间?

本文发布于:2023-07-06 20:34:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1054507.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   房间   玩家   Unity3D   PUN

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!