So I have an object that is created by a Manager object script with InstantiateRoomObject at Start().
PhotonNetwork.InstantiateRoomObject(world, Vector3.zero, Quaternion.identity);
The World object contains a mazeSpawner script that generates a maze in Start(), based on a random seed.
RandomSeed = Random.Range(11111, 99999);
Random.seed = RandomSeed;
In order to sync the maze for all players, at first I put a PhotonView on every maze object but that led to 999+ photonView IDs, so instead I figured I could probably just sync the maze seed across all players.
I gave up trying to use the customProperties, and instead am going with RPCs, but I have been unable to get it working and I have been trying for more than a day now.
I tried calling this at the beginning of the Start(),
photonView.RPC("SetSeed", RpcTarget.All);
[PunRPC]
public void SetSeed()
{
RandomSeed = Random.Range(11111, 99999);
Random.seed = RandomSeed;
}
But this results in all players still having random, separate seeds AND only on the master’s side, does the maze fully generate. For the other clients, only about half the maze is generated, as if it were interupted.
Next I tried calling the RPC using IsMasterClient which led to only the Master client to getting a randomized fully generated maze while for the clients, they had seeds which exceeded the set range and even went into the negatives and the maze was again only about half.
Afterward, i tried various combinations of switching the Random.Range and Random.Seed lines from the RPC to the Start(), and calling those lines and the RPC in the Start() or IsMasterClient. But I just got similar, incorrect results.
**So how I can sync a random.range value across a server for all players, so that that value can be used for a random maze generator seed? **