Photon RPC target.All sends info only to the client. * Not Working

Hi everyone, I am trying to create a multiplayer game and am trying to syncronize a manterial through RPCs. now, when I call the function calling the RPC

    public void SyncColor(int c)
        Debug.Log("Sender: " + photonView.ViewID);
        gameObject.GetComponent<PhotonView>().RPC("setColor", RpcTarget.All, c);

everything seems fine. In the unity console during runtime it logs: “Sender: 1001”
And when the RPC function gets called:

    public void setColor(int c)
        Debug.Log("Reciever: " + photonView.ViewID);
        GameObject[] blocks = new GameObject[blockParent.transform.childCount];
        for (int i = 0; i< blockParent.transform.childCount; i++)
        blocks *= blockParent.transform.GetChild(i).gameObject;*

Debug.Log("Blocks length: " + blocks.Length);
for(int i = 0; i<blocks.Length; i++)
blocks_.GetComponent().material = blocks*.GetComponent().materials*

Debug.Log(“Recieved stone”);

In the first row it should log twice as there are 2 players in the current game. it should log:
"Reciever: 1001"
"Reciever: 2001"
And instead of this it only logs
"Reciever: 1001"
I don’t know why this is happening. can anybody help?


Hey there,

you somewhat have a false understanding of how this is supposed to work so lets try to clear things up.


We have 2 Player, each running their own program instance. Each Player (lets call them A and B) both instantiated a playerobject that they own, so when you call photonView.isMine it should say true.

Now when you call an rpc on A’s player with RpcTarget.All this will go to all other program instances the copies of A’s player object and trigger the given function there. But since you as the caller of an rpc are also included in RpcTarget.All, the rpc will also bounce back to you. But the only thing that you as player A will see in your program instance and debug log is that you sent 1 message and received 1 message. Player B on the other hand should have a Debuglog telling him that 1 message for the copy of A’s player object was received.

So from what you are telling me at this moment everything should be working fine as far as the logs are concerned.

Let me know if something was unclear and if you need further help on this.