用户加入时不调用 OnJoinedRoom 方法

编程入门 行业动态 更新时间:2024-10-27 17:16:35
本文介绍了用户加入时不调用 OnJoinedRoom 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用 Unity Pun2 开发服务器.

I am developing a server using Unity Pun2.

我的问题是当用户参与时没有调用 OnJoinedRoom().

My problem is that the OnJoinedRoom() is not called when the user participates.

有两种情况

创建房间并首次添加时 - 称为

When making a room and adding it for the first time - called

然后,当另一方加入房间时 - 不叫

Then, when another party joins the room - not called

public override void OnJoinedRoom()
{

    if (PhotonNetwork.CurrentRoom.PlayerCount == 1)
    {
        PhotonNetwork.LoadLevel("RoomFor1");
    }
}

++我的问题是主客户端称为 OnJoinedRoom,但其他客户端不称为 OnJoinedRoom.

++ my problem is that the master client is called OnJoinedRoom, but the other clients are not called OnJoinedRoom.

推荐答案

使用 OnPlayerEnteredRoom() 检查是否另一个玩家进入了你所在的房间

use OnPlayerEnteredRoom() to check if another player entered the room you are in

使用 OnJoinedRoom() 检查自己是否成功加入房间

use OnJoinedRoom() to check if you yourself have successfully joined a room

这篇关于用户加入时不调用 OnJoinedRoom 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-28 17:38:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1176879.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:入时   方法   用户   OnJoinedRoom

发布评论

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

>www.elefans.com

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