Network game random number synchronization issue

Options

Hi,


I'm developing my first networked game over Photon and I have been really frustrated over the synchronization of it.


Basically my game is two players, being able to bet on either red or green, and betting a certain amount of chips on each. My checks work fine, the only problem is that it seems to set the result PER user rather than being a global number that returns to everyone.


ReturnColor is called whenever the player's opponent has bet, and sends this function call to all (as you can see with the RpcTarget.All)


DisplayMessage is called always on RpcTarget.Others to notify when their opponent has bet, and as a result, will hit the code in the screenshot below


(first player hits first block of code, second player hits both blocks of code, however, creating an instance of NetworkManager on each) ^^



here is the NetworkManager script attached to the GameObject :(


However, regardless, even WHEN trying to ensure that the result stays consistent across both objects to ensure that the function SetResult ONLY gets called once, somehow, it gets called twice and there is the possibility of two different results per player.



The object NetworkManager spawns in both players, and gives them all of these individual statistics, but even still, a global object with a global int (ensuring that its only called once) SHOULD return the same result to both clients. If anyone could help when it comes to function desynchroinzation, it would really help. I am very new to Photon and I have been googling like crazy, and haven't found anything that could help :( I know what I'm supposed to do, it's just the implementation that's driving me nuts