Search Unity

Third Party Photon switch from offline to online mode

Discussion in 'Multiplayer' started by Ewu_Uwe, Jan 10, 2021.

  1. Ewu_Uwe

    Ewu_Uwe

    Joined:
    Apr 13, 2020
    Posts:
    21
    Hi, I make a 2d online game, but you should can play it offline,too.So when you play in your world, it's offline, but you can make it online when you're already in the world and playing, so your frineds can join. I used PhotonNetwork.OflineMode for this, but if I change it to false, the Player gets Destroyed. Thanks for your help.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    The offline mode is meant to simulate online gaming, yes. But if you go online, the client switches the room and that will clean the current state.
    Taking the offline networked state online can be quite complicated, if others would also be able to spawn objects, then join a room. Each object needs to get synchronized (announced it exists) and identified (any object's ID must be unique across all clients, who created them offline, not knowing the other's state).
    This is not supported by PUN 2 out of the box, sorry.
     
    BetaMark likes this.
  3. Ewu_Uwe

    Ewu_Uwe

    Joined:
    Apr 13, 2020
    Posts:
    21
    Thanks for your reply, do you have an idea how i can do it without this function?
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    It depends on what you really expect from this.
    You can create anything you like offline, as long as you know how to eventually send the creation to others in an online room.
    Do you just want others to visit your place? Then I'd approach this as kind of "save game". You serialize the room / creation in a way that's share-able (lean to send in the network, not GBs of data). Push it online to some server to get an ID for this. Then create a room and put the content's ID in the properties of the room. Anyone who joins, can load the level and just interact with you.
    Something like that maybe ...
     
    BetaMark likes this.
  5. Ewu_Uwe

    Ewu_Uwe

    Joined:
    Apr 13, 2020
    Posts:
    21
    Thanks for the suggestion, i will try that