Rooms, Unity Scenes and PUN

Options
I've a map (a unity scene), from which players can choose a particular area, each area will be online multiplayer (like GTA Online), in these areas people can run around and see other players too. From within these areas players can choose to play particular games (likes Chess, for eg), where there will be a match making and the game will start. How I go about making this? Currently, I have a "Launcher" GameObject in my scene. So when the map scene loads the scene makes connection with the Photon Server and get gets it connected. Then, when a player clicks on a area, lets say Area A, I FindOrCreate a room with the same name and then load the Area A scene using Photon. But the problem I'm facing is, is whenever a new player joins the room a brand new scene gets created for all the players who are already in the scene, and then every one gets teleported back to 0,0,0 (the spawn location), and all the character meshes collide and its a human fireworks. What am I doing wrong?

Answers

  • Tobias
    Options
    You posted this in .. various places. Did you figure out what's up?
  • gekido
    gekido ✭✭
    Options
    I'm trying to figure out a similar scenario:

    I'm trying to handle multiple locations that are 'persistent' within the game, for example:

    - apartment
    - social area
    - game zone A
    - game zone B

    But I'm failing at the basic flow for instantiation of objects and getting them to sync.

    Are there any examples of how to manage scenes & objects in Photon when you have AutoSync scenes turned off?

    This feels like it shouldn't be so hard, but every example I find with photon is a traditional counterstrike style map-based scenario that forces players to switch maps when the server switches maps.
  • gekido
    gekido ✭✭
    Options
    So far, what I have is:
    - players connect / join rooms - all good. I can see the players in each client
    - using a player property to define which location the user is in - that's working
    - if I join a specific room, use photon.instantiate to create the character - which works fine for the first room, can see from both sides

    the issue comes when I want to jump from this first room to another. How do I handle destroying the character in the first scene properly so I can respawn them in the new location?

  • gekido
    gekido ✭✭
    Options
    I guess my question is: do I need to manage the objects that I have instantiated and manually destroy them when loading new scenes? Is there a proper way of doing this cleanup with Photon?
  • gekido
    gekido ✭✭
    Options
    I guess another way of stating this is:
    - since photon rooms and unity scenes aren't directly tied together, how do I manage objects that are in a single photon room across multiple unity scenes?

    If I have 2 unity scenes:

    - LocationA
    - LocationB

    and 2 users that are in the same Photon room:

    PlayerA : GameObject & PhotonView
    PlayerB : GameObject & PhotonView

    , what is the recommended want to manage the GameObjects and PhotonViews for the players when they move from one Location to another?
  • gekido
    gekido ✭✭
    Options
    Thanks @Chr0my - DestroyPlayerObjects might be what I'm looking for - although the players are still technically in the room still, just want to clean up after them when they jump to a different location.

    Let me give that a try
  • gekido
    gekido ✭✭
    Options
    Still looks like I'm going to need to have a custom visibility management layer to handle objects that aren't in the player's current location. Hmm...
  • @Tobias No I didn't, I had no clue what was going on and even after posting it everywhere sadly I couldn't fix it. I ended up switching service to SmartFoxServer and now everything works just fine :smile:
  • gekido
    gekido ✭✭
    Options
    I'll continue my experimentation in another thread