简体   繁体   中英

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

I'm trying to send an Rpc to a specific Player, but I can't use the get function from the Player class, I have to setup a player variable first, but I can't have the player variable equal anything except null if I can't reference the player. I have been wholly unable to come across any information after scouring the internet for an hour.

I've tried using references to photonView and tried to reference Player through GetComponent(); which always ended in the error "ArgumentException: GetComponent requires that the requested component 'Player' derives from MonoBehaviour or Component or is an interface"

Before the Photon change to Photon 2 it worked fine and my code was:

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

And after trying for a couple hours to fix it I have this:

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

I expected to be able to find a player by id/actor number without needing a player referenced already, but it appears that I need to have that reference. It doesn't make any sense to me as to why or what I've done wrong.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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