How do I make all players access a shared GameObject?

Options
Dear all!

I have a simple level for 2 players with one button that is supposed to change the background color of the level. I setup the background as a prefab in resources and have it's color serialized and photonviewed as a Vector3. I have set the photoview to reliable, takeover. But it never gets taken over and only master sends data and clients only receive data. How do I make clients send data to the master as well?

Best regards
Bukeikhan Omarali

Comments

  • Hi @hedgehoginmist,

    as long as you are the owner of the game object you will call OnPhotonSerializeView as 'writer', so stream.isWriting is true. Means that only the owner is able to make network related changes to the object. What you can do using this approach is to take a look at Ownership Transfer to take over the object before changing its color.

    However I guess OnPhotonSerializeView might be the wrong approach for this scenario, so I would recommend you taking a look at RPCs. When implementing this you can use the button to call a public function on the instantiated prefab which furthermore uses its PhotonView component to call a RPC with a color (use its 3-4 float values in this case) parameter and apply the new color within the called function.