Room properties

Options
Hello! I am new to Photon and I after using it for a while, I have to say that I am most impressed. I was looking through the reference document and three statics in particular caught my attention: "static bool autoCleanUpPlayerObjects", " bool autoCleanUp" and "static bool automaticallySyncScene". The problem is I don't know how to use these three correctly, do I have to set them as a property of the room when it is created? It would be much appreciated if someone could help me! Thank you in advance.

Comments

  • Tobias
    Options
    Thanks for the nice words. I'm happy we could impress you :)

    autoCleanUpPlayerObjects: Can be set to disable cleaning up GOs when players leave the room. This can be nice in game worlds where players drop stuff or similar but you will have to clean up those GOs in the Master Client eventually. This significantly changes how your game is working and you most likely use the same setting for all rooms anyways.
    autoCleanUp: Is a property of the Room class and will be set according to autoCleanUpPlayerObjects. It can't be set.

    automaticallySyncScene: Is used in conjunction with PhotonNetwork.LoadLevel. If the Master Client switches the scene, all other players in the same room, will do that, too. In some cases, this makes it easier to switch from some game-setup scene to the actual level players decided on (you could do that even while players are in a room together, of course).
  • Borzi
    Options
    No problem! Thanks again for the quick reply. So your saying - I will never have to call autoCleanUp & automaticallySyncScene with script because they get called automatically (autoCleanUp is automatically in every room, autoSyncScene is called with PhotonNetwork.LoadLevel). Could I call "autoCleanUpPlayerObjects" together with OnPhotonPlayerDisconnected so as to delete all objects that this player has spawned?

    Edit: I also had another question about the Scene sync: in my game, the player's can join rooms but they will still be in the menu. What if a room is already in a match (have loaded a different scene). Will this command load that scene automatically or should I add a script that does it for that player?
  • Tobias
    Options
    You don't really "call" autoCleanUp or automaticallySyncScene. Those are properties (fields) you can set and they are used throughout the lifetime of your game.

    If you set automaticallySyncScene = true when your client starts, all clients will automatically load the same level that the master client loaded. That's implicit. You don't have to call something, except loading a new level. In best case, you can do that with PhotonNetwork.LoadLevel().
    For your second question: automaticallySyncScene = true should do the trick and get anyone in the same room as the Master Client loaded.

    You also don't have to call autoCleanUp. It's true by default and when someone leaves, the others and the server will clean up the GameObjects of that player.
    If you set it to false when your client starts, then GameObjects will stay in the room, even if someone leaves.
    No matter what, OnPhotonPlayerDisconnected will be called when someone leaves.
  • Borzi
    Options
    So how could I set "automaticallySyncScene" to true?
  • Tobias
    Options
    In your code, somewhere before clients join a room (e.g. before you connect):
    PhotonNetwork.automaticallySyncScene = true;
  • Borzi
    Options
    That easy? Awesome!