Move only my unit using RPC

Options
I have a click-to-move script and when 2 or more players joined, if one of them clicks the map, other players's units move too, how can i do so he moves only his character and im moving only mine and so on... I will leave the scripts bellow.
https://pastebin.com/vRPPqVTH <- script to get the movement
https://pastebin.com/7Lb1WCdm <- script to send the movement.

Comments

  • Hi @LokiOfJotunheim,

    before sending the RPC you should check the isMine condition of the PhotonView component. You basically should do this before any Input is processed. In your case it should look similar to the following:
    void Update()
    {
        if (!photonView.isMine)
            return;
    
        // Do something
        // In your case: check MouseButton and send RPC (if click is valid)
    }