How to sync variables across clients?

The whole answer can be found below.

Please note: 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! And we offer you support through these channels:

Try Our
Documentation

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.

Read More on
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 to sync variables across clients?

okMajd
2022-02-21 14:55:54

Hello, I have a group of gameobjects (30+) which all have variables that are randomized on start. I need to sync these across the client to make sure they have the same material, variables, etc as it is necessary for gameplay. How would I do this? I don't think I can use RPC because I would need to do that for every variable manually and keep a list of every object at all times. Thanks

Comments

Tonny
2022-02-22 17:16:00

Hello i'm using RaiseEvent with CacheOption = AddToRoomCache for saving value for users who will join later then event

Tobias
2022-02-23 12:47:32

Read about Synchronization and State. And or read about sharing a seed value, then using the pseudo-random number generator to generate many values from this.

Cached events are not the best approach.

Back to top