Change material using PunRPC Call not working?

Hey, So im using a punRPC call to change the players material based on their ID, it is updating locally, but it isnt updating for other players on the network

using the line below in the start method to call the RPC

GetComponent<PhotonView>().RPC("SetColor", RpcTarget.All);

and in my function i have this


  public void SetColor()


    if (photonID == 1001)


      Material[] mats = new Material[] { colors[10], colors[0], colors[0] };

      this.transform.FindChild("Astronaut").gameObject.GetComponent<Renderer>().materials = mats;



  • This happens because you need to define the material as a parameter in the PunRPC function. You can't expect the other clients to know what material to change to if it isn't identified. I'm going to be honest though, I don't think you can directly sync materials with PunRPC functions so I'm just going to show you how I would've done it.

    Let me know if you don't fully understand what's going on here, I'll try to explain it how I understood it.

  • Gameboycool5
    edited September 2022