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.

Synchronize an array between players

2020-11-09 22:19:34


We are using PUN in our project. We have a scenario where we need to sync an object between players. This object has a collection of geo coordinates in an array (or a list). These coord are 2 doubles values
There maybe a lot of these objects (several hundreds on a map)

I guess I may have to increment a counter or something to fire a serialization of the object.

That being said, is it a good choice to use photon views with unreliable on change sent? That would make a lot of photon views, but the alternative is to manage the syn with RPC, kind of reinventing the wheel...


2020-11-10 21:03:41

I think best choice for this situation is firing RPC or RaiseEvent.Without any optimization a lot of photon view might be exceeds limits (500 msg/sec). Sending rpc frequently from more objects still could be problem. One controller over these objects may help.
If you can sync these object when they need (e.g. when they are rendered) photon view + serialize view solves your problem.

Simple double array sync with RPC if I did not make any mistake:

photonView.RPC("SyncArray", RpcTarget.Others, (object)doubleArray);

void SyncArray(double[] array)
//Game logic...

Back to top