Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

External Server to handle clients

Discussion in 'Multiplayer' started by moynzy, Mar 2, 2016.

  1. moynzy

    moynzy

    Joined:
    Oct 22, 2014
    Posts:
    82
    Hello, I have heard about Unet, the successor to the MasterServer API (correct me if I am wrong).

    From watching tutorials on YouTube, I have seen that a client, can HOST a game and JOIN a game, which I find is funny, because I thought this was unsafe and can lead to cheating. For example, if you have a server on a non client machine, clients will tell the server, I am moving my position, the clients send their transform over the network to the server, and the server tells every client to move.

    What I have done at the moment is a dirty prototype, where the "server" listens for connections, the client logs in, presses the play button and then when the server has two clients that want to play it should open up a headless server, or an instance of the game, where it is the server, the clients then open up a new window, of the game (like in dead island epidemic/leagues of legend) and the game begins.

    Is this possible? If not, will I have to use the "Client1 hosts as server and player, "Client 2 enters IP and port, and joins", like in Minecraft)

    I will post a video of the implementation once it finishes uploading so you can get a visual representation of the my situation.

     
    Last edited: Mar 2, 2016
  2. srylain

    srylain

    Joined:
    Sep 5, 2013
    Posts:
    159
    While removing a player's ability to host a server will remove any sort of cheating that could cripple a game, it won't stop people from intercepting the DirectX or openGL calls to create cheats that allow you to see people through walls or auto-aim. I'm not sure if Unity supports something like this out of the box, but people are also able to tamper with their data packets sending false position and attack data.

    But unless you're making the next big multiplayer game, I wouldn't worry about cheating. If you have a very small playerbase, it's less likely that it's going to get hacked.
     
  3. moynzy

    moynzy

    Joined:
    Oct 22, 2014
    Posts:
    82
    crynryan, many thanks for the reply. I guess you are right, I'm not making the next big AAA game with multilayer functionality, just a demo to learn and test.

    In your opinion, from watching the video/ reading the post, should I keep that server, just as a login server that talks to the database, or would you say use Unity Unet/PUN?
     
  4. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Personally, I am using uNet for client and dedicated server. It seems to work well.

    Cheating is a tiny issue (percentage wise). Of all your playerbase, only a tiny fraction will be cheaters. Of all the data packets they send to the server, only an even tinier fraction will be cheats. You can write a ton of code to try to catch cheats (which they'll find ways round), and in doing so, slow down the game for everyone else; or you can have your GMs on the lookout for cheats, and note reports from other players.
     
  5. moynzy

    moynzy

    Joined:
    Oct 22, 2014
    Posts:
    82
    Whippets, I have decided to use UNet, however, the server code I have written, can that come in handy apart from the login functionally? Do you reckon I can give the server available IP addressed for clients, this way I won't need to use Unity's service to host matches on the website?
     
  6. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Yes, that's exactly what I do. I have a dedicated Unity instance running headless as the server, with clients that connect directly to it. I don't use any of Unity's master-server or match-server services.

    I actually have more than one Unity instance server - one for each game zone.
     
  7. moynzy

    moynzy

    Joined:
    Oct 22, 2014
    Posts:
    82
    Thanks for the reply,

    Yes, to obtain running headless as the server, you must use -batchmode right? I am using a personal edition, not pro. Am I entitled to this?

    One more question if you don't mind answering, would you create one project for client, and one for server, or one project for both. Run the server headless, and give it the ability to host as a game, one hosted game opens an instance of the game, or as you described an instance server?
     
  8. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Yep, pro and personal are the same, bar the splash. Run -batchmode -nographics for headless. I like running Unity as servers, because the colliders and physics is all there for you - so same terrain/environment can be used on client and server (though I remove all cameras, renderers, etc from servers).

    I have a world split into walled-garden zones, with one server per zone. But any architecture you want should work fine.