[Help] How to sync materials of my players' MeshRenderer.

Options
Hi everyone, I'm kinda new to networking, and I'm stuck with a problem about synchronisation between two players materials :

I have a game with a launcher (I followed the basic Photon Tutorial), in which players are spheres placed on cubes. The players can only jump, shoot left and shoot right. Almost everything is working (I see players moving in both of the screens, I see them shooting, losing life etc...) but the real issue is about players' color.

When two player join, they launch a room, and a player prefab is created.
The player script has a Material variable, in which a Material from the Resources is applied, depending on the player's ID. Again, this works perfectly for the local player : the first player is red on the first screen, and the second player is blue on the second screen .

But the problem is about seeing the others' players color : on each screen, the other player appears white (basic color of the prefab). I managed to sync strings, ints, movements, but I can't figure out how to sync that.

I tried to send the material using the IPunObservable, but it returns an error...

Thanks for your help !

Comments

  • Hi @KeldaWind,

    Materials can't get serialized by default, you would have to register a Custom Type therefore. Since I don't know, if this is possible at all, I would prefer using another approach, where you either synchronize the name of the used Material or synchronize the Color of the Material (either as Vector3 or float[] - those types are serializable by default). You can do this for example by using the Instantiation Data when using PhotonNetwork.Instantiate or by using a RPC after the object has been created.
  • KeldaWind
    Options
    Hi @Christian_Simon ,

    Thanks for your response ! I guessed there was no simple way to get to that, but I just wanted to make sure that I wasn't going in the wrong direction ^^

    RPC seems pretty powerful, I'll focus on it starting from noow.

    Thank you again, have a nice day !