繁体   English   中英

你如何在Photon Unity Networking 2中引用Player类?

[英]How do you reference the Player Class in Photon Unity Networking 2?

我正在尝试将Rpc发送到特定的播放器,但是我不能使用Player类中的get函数,我必须首先设置一个播放器变量,但我不能让播放器变量等于除null之外的任何内容我无法引用播放器。 在互联网上搜索了一个小时后,我完全无法收到任何信息。

我尝试使用对photonView的引用,并尝试通过GetComponent()引用Player; 总是以错误结尾“ArgumentException:GetComponent要求所请求的组件'Player'来自MonoBehaviour或Component,或者是一个接口”

在Photon改为Photon 2之前,它工作正常,我的代码是:

other.photonView.RPC("Reflect", PhotonPlayer.Find(other.GetComponent<PhotonView>().ownerId))

在尝试了几个小时来解决它后,我有这个:

other.photonView.RPC("Reflect", GameObject.Find("Game Manager").GetComponent<Player>().Get(other.GetComponent<PhotonView>().OwnerActorNr));

我希望能够通过id / actor编号找到一个玩家而不需要已经引用的玩家,但看起来我需要有这个参考。 对我来说,为什么或我做错了什么都没有任何意义。

它应该很简单,因为PhotonView类有OwnerOwnerActorNr ;

photonView.RPC("RpcMethodName", photonView.Owner));

暂无
暂无

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

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