I am using Unity3d 2018 + Photon Unity Networking . I have some kind of magic with the PhotonView component PhotonView

There is a PhotonView on GameObject , I use it to synchronize the movement of the character. Script - https://pastebin.com/FLx0TKYA

This script also has the RPC_Throw() method

When I call PhotonView.RPC ("RPC_Throw"), a NullPointerException occurs as if there is no PhotonView component, but it exists! I use it in real time to move the character using the Move () method, and in the editor I also see what PhotonView is, the variable is NOT empty. Screen - http://joxi.ru/LmG8KwphwBjOl2

Ie, PhotonView exists for one Move() method , but not for the other (and in the same script).
What is the problem?

  • Are you sure that the error "NullPointerException" occurs because "supposedly" (PhotonView) PV (took the name of the variable from the script on your link) = NULL? In my opinion, the error should be sought in the arguments of the RPC method, i.e. PV.RPC("RPC_Throw", RpcTarget.All); - Alexander Danilovsky
  • I have already figured out what the problem is, but I still solve the problem. The problem is this: when you click on a button, the Throw method works for ALL players, not for the person who pressed the button - Vitaly Belousov

1 answer 1

The problem is this: when you click on a button, the Throw method works for ALL players, not for the person who pressed the button. I added the PhotonView.IsMine check and also figured out the links.