Search Unity

Multiplayer Server- Client architecture | Photon

Discussion in 'Getting Started' started by K_B, Apr 17, 2015.

  1. K_B

    K_B

    Joined:
    Apr 17, 2015
    Posts:
    5
    What is the correct way to set up a multiplayer game in unity?

    I thought for multiplayer games it is ineventible to have a server - client architecture to prevent hacking and keeping everything in synch. A client sending input and the server determening the resulting events.

    1. Digging around youtube I have found 1 tutorial which is following this approach using 2 projects ( 1 Server | 1 Client) and RPC calls.
    2. I have seen Photon and they seem to connect to a cloud which handles game rooms and chat but every script written is still part of the game client. Is using Photon a common and fail prove approch? I don't see how a multi player without server code can work.
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    Photon is designed for cooperative games with small groups where one person is acting as the host and everyone else connects as clients. The concept works quite well for a number of games such as the Borderlands and Civilization series.

    Preventing cheats and exploits is generally not handled by the developer as the host can simply kick the user from the game or allow them if everyone is doing it. Occasionally a game will disable achievements in Steam if a game file is modified, but that's about the extent of it that I've seen.
     
    Last edited: Apr 18, 2015
    OboShape likes this.
  3. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Ryiah likes this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You can get a photon server option if you need server side code. Its expensive through.

    Many games have successfully operated without a dedicated server. Most of the RTS genre do this by simple cross checking. Each client runs the same simulation, and any client that deviates from this must be cheating.
     
    Ryiah likes this.
  5. K_B

    K_B

    Joined:
    Apr 17, 2015
    Posts:
    5
    Thank you for everyone's answers.

    I have worked through a long multiplayer tutorial just for the sake to learn how everything is working and I have to admit that I am surprised that PUN games really work the way they do. I always imagined that if there is some a place where the game can break someone will put in the effort to exploit it. In my opinion if you have to kick a player from a game the damage is already done.

    Luckily for my next project this is not important as there is no benefit from cheating or changing values but in the future I think I will follow the approach of @BoredMormon and let the clients randomly check each other and see if at least the key values (e.g. position or health) are reasonable.
     
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    Most people I know who are actually concerned if someone were to cheat in their game will simply put a password on the game itself and only give the password to those they trust. Otherwise I've found those who play cooperative games are less concerned with cheaters than those who play games with persistent worlds.

    This method will only minimize the degree of cheating that can take place. If you're concerned about cheating your best bet is to simply keep dedicated server hardware and only allow the server to make decisions. This can be very expensive though which is why typically only MMOs go down this path.

    Cooperative gameplay on the other hand only requires a basic matchmaking server and those are very cheap to maintain.