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.

How do I sync character colors?

2021-05-30 01:06:52

I'm trying to have a system where a player joins a room, picks a color, and their character is instantiated as that color.

I set the color as a Player Custom Property in SetCustomCharacter(), and then I'm trying to get a way to link the player prefab to the Photon player. Right now, I'm trying to set the color like this:

The playerModel.GetComponent<> ... .ActorNumber doesn't work because it's only locally setting the ownerID, and for everyone else it returns 0. What is the correct way to do something like this?


2021-06-21 09:52:38

There are plenty of ways to get this working.
I would recommend one of those two:
a) If the players select the color before instantiating the character (and the color never changes afterwards), you can send some "Instantiation Data" with the Instantiate. A script on the prefab should read this and apply the color.
b) Store the color as a Custom Property of each player. Remote clients can read each player's color property and apply it.

Back to top