如何使用PUN Unity3D将玩家重新加入房间? [英] How to Rejoin a player to a room using PUN Unity3D?

查看:412
本文介绍了如何使用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将玩家重新加入房间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆