3
\$\begingroup\$

In my Photon powered game, I have a shotgun weapon and when a player fires a bullet, I call an RPC on other clients and it's bullets get direction from a random function, Random.Range, and on different clients it acts differently.

How can I sync this so in every client, the bullets behave the same, i.e. in this case they would have same directions?

I tried setting the same seed via Random.Seed but it didn't help.

\$\endgroup\$
2
\$\begingroup\$

You'll need to create your own random number generator object and synchronize it on all clients.

Also make sure the order is deterministic even with lag if two clients shoot at roughly the same time the order of RNG polling might be reversed on some clients due to network lag if packets arrive in the wrong order.

The other option is to build an identical pseudo-random direction table on all clients and pass an index into the look-up table.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.