簡體   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