Rooms, MYSQL database and authoritative server

Options
Hello

Am I right in saying a Photon 'room' is just a game? The documentation is rather confusing. Would I be able to remove the entire rooms/lobby concept and simply have my game run from one server to which all clients connect once logging in? Could someone perhaps provide me with a tutorial on doing this? I suppose the server would come down in size after removing what I don't need, I just don't know how to go about it.

Also I don't understand why I would need to look at having a database integrated with the server. Can't I just have the Unity client do a check (with the WWW class) connecting to a PHP page and then relaying information back to Unity? E.g. enter login information, send this as a http://www.form to a PHP page, await results and have the client output whatever is relevant. This is what I was doing whilst using the normal Unity networking; is this not a good solution for logging in, storing character data and so on?

Lastly, is it going to be more hassle than it's worth to have some important decisions made on the server (FPS shooting, basic collision/shot detection etc)? Any tutorials floating around for setting up an authoritative server model? Or would I be better of keeping everything decided client side?

Cheers

Comments

  • 2Kin
    Options
    I didn't try but it's possible to ignore the system of lobby and enter/create directly a room.
    You have to set PhotonNetwork.AutoJoinLobby to false, and then use OnConnectedToMaster.
    I've never see an example of it.
    OnConnectedToMaster
    Called after the connection to the master is established and authenticated but only when PhotonNetwork.AutoJoinLobby is false. If AutoJoinLobby is false, the list of available rooms won’t become available but you could join (random or by name) and create rooms anyways. Example: void OnConnectedToMaster(){ ... }

    Note that in the "normal Unity Network", a lobby system also exists.

    There is no need of using a database in Photon, it's up to you to decide if you need one or not for your game.

    For your last question again, it's up to you. But if you want an authoritative server, you may take a look at Photon Server.
  • Tobias
    Options
    2Kin: Thanks for helping!
    It's right: You don't have to use the lobby and room listing. In that case, simply use OpJoinRandom (in PUN: joinRandomRoom) and if that fails, cause no room is available, create one!

    I think I use that in this sample:
    http://doc.exitgames.com/photon-cloud/M ... 0Tutorials

    AutoJoinLobby is true by default but you can set it on start of the app once and forget about it.
  • Tobias wrote:
    2Kin: Thanks for helping!
    It's right: You don't have to use the lobby and room listing. In that case, simply use OpJoinRandom (in PUN: joinRandomRoom) and if that fails, cause no room is available, create one!

    I think I use that in this sample:
    http://doc.exitgames.com/photon-cloud/M ... 0Tutorials

    AutoJoinLobby is true by default but you can set it on start of the app once and forget about it.

    Thanks. So a room is just a game? I don't want more than one game instance running, I just need the one on the one server; will I still need JoinRandomRoom? What of making the server authoritative and the database question?
  • Tobias
    Options
    Just one room: If there's only one room and you work with the server code, you can auto-join users when they connect. Having the room helps if the players want to communicate, cause it already keeps a list of users in it, etc.
    If you want to avoid the code modification, you could keep join random. There's no reason not to use it.
    Anyone who is in that room gets anyone else's events (sent via Operation Raise Event) and updates (join / leave). Keep this in mind if you have a lot of users in one room.

    About database usage: Of course you can do this via php and http calls on an external server. Integrating this into Photon directly is just one option!

    Authoritative Server: This is often asked and there's no great tutorial for this. The reason for that is most likely that each game is different and developers have different requirements for their games, engines, etc.
    I would try to get away with as much client side checking as possible. If real money is used in one way or another, then do everything on the server. Otherwise, do the easier thing or what interest you most.
  • Okay, I'll use the JoinRandomRoom and if none exist, CreateRoom. If I do this, does this mean anyone who joins after the first person (who creates a room since none exist) will end up in the same room? How many players can be in a single room? I don't want to separate my game up into several areas/rooms/games; I just need the one.

    For syncing player positions and things is it a good idea to use the PhotonView observe? Is this not going to slow down the game if there's a lot of players on screen? Is it more efficient to sync positions and such with RPCs?
  • Tobias
    Options
    You can put as many players into a room as is technically possible with the amount of messages they create and receive (everyone in a room usually gets everyone else's updates). There is no hard limit but don't expect this to be higher than in shooters or so. Around 16 to 32. Depends on your game.

    Unless 2 players try to join a random game at exactly (!) the same time, they will always end up in the same room (cause a room is only created when none is available). That is, if you leave the max players at 0 (which is actually unlimited).

    Within PUN, it's not more efficient to update positions with RPCs. Better use PhotonView observe.
    PUN itself is not built to run with a big amount of users in one room though. You might want to reduce the update frequency (described in the doc).