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\$

1 Answer 1

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\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .