The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

2018-07-24 11:00:07

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 !


[Deleted User]
2018-07-24 14:07:17

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.

2018-07-24 14:50:47

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 !

Back to top