PhotonNetwork.automaticallySyncScene = true explain please?

Options
I have this line in my app: PhotonNetwork.automaticallySyncScene = true

So I presumed this means scenes are synced between all?

So when I have created and joined a room as master and then the client joins I thought if master called a method to hide a specific canvas this would propagate to all, but it does not it only hides on master?

I tried adding a PhotonView to the canvas but this just observes the rect transform not the active state?




Comments

  • HI @piginhat,

    I guess you misunderstood PhotonNetwork.automaticallySyncScene. It doesn't mean, that the state, position or something else of all availabe objects are synchronized - unless you are doing that on your own. It means that the currently loaded scene is the same across all clients, if the MasterClient used PhotonNetwork.LoadLevel to load another scene. For example if the MasterClient loads Scene B, all other clients will load Scene B as well.
  • piginhat
    Options
    Ah, OK thanks. So is there no way I can control the active state of a canvas across players? I see the PhotonView will only observer the rect transform but not the active state.

    What do other folks do?

    Thanks
  • You can control this. If you have already attached a PhotonView component to it, the object will be controllable by the MasterClient and he can send RPCs for example. Another option would be raising an event by calling RaiseEvent. Even using OnPhotonSerializeView would work, but this is not recommended in this case because you don't have frequently changes.
  • piginhat
    Options
    Ok, so in my situation I have this:

    A canvas that has a master view panel and a client view panel.

    Master logs on and creates a room and sees the master view panel, client logs in and joins the room and sees the client view panel.

    Master starts the game and sets the master view panel and client view panel to hide so now both players see the game scene etc.

    There is a "Leave Game" button that when the client taps it I intended to make the client view panel appear on the clients device whilst the master still sees the game scene.

    If howver the master taps the leave game button then it sets both master view panel and client view panel to show so now both are back at the start.

    Am I misunderstanding completely?

    I did start to work through the PUNBasic Tutorial but that seems a bit off topic / hard to follow so I followed a YouTube series that "I think" got me a good way into using PUN.

    I really wish there was an up to date step-by-step video on PUN from the PUN team available. Even better would be an official book ...

    I'm amazed at what PUN can do, just think I am missing the plot a tad :neutral:








  • Master logs on and creates a room and sees the master view panel, client logs in and joins the room and sees the client view panel.


    Good, we have an entry point and this sounds good so far.

    Master starts the game and sets the master view panel and client view panel to hide so now both players see the game scene etc.


    Do you already have this working? If not you can either use a RPC on the game object (if it has an attached PhotonView component) telling all clients to disable it or you can use RaiseEvent with a unique EventCode. When using RaiseEvent the game object doesn't need a PhotonView component.

    There is a "Leave Game" button that when the client taps it I intended to make the client view panel appear on the clients device whilst the master still sees the game scene.


    You can do this locally on the client. I thing there is no need to synchronize this action in this case.

    If howver the master taps the leave game button then it sets both master view panel and client view panel to show so now both are back at the start.


    You can do this the same way you previously disabled the view. RPC or RaiseEvent.

    Hope that makes things more clearly for you. If you have further questions, feel free to ask.
  • piginhat
    Options
    Thanks, really appreciate the feedback! I am revisiting the PUN Basic tutorial to see if I can complete it and hopefully fill in some blanks.

    But you answer helps no end :):)
  • Hipshot
    Options

    You can control this. If you have already attached a PhotonView component to it, the object will be controllable by the MasterClient and he can send RPCs for example. Another option would be raising an event by calling RaiseEvent. Even using OnPhotonSerializeView would work, but this is not recommended in this case because you don't have frequently changes.

    Does this work in editor? I am setting PhotonNetwork.automaticallySyncScene = true in the start function of my connect and join script. The scene changes for the master, but not the client in editor?
  • S_Oliver
    S_Oliver ✭✭✭
    Options
    @Hipshot you have to change/load the scene with PhotonNetwork.LoadLevel