Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Authoritative server that can assign players as game hosts?

Discussion in 'Multiplayer' started by GD-Darren, Feb 12, 2016.

  1. GD-Darren

    GD-Darren

    Joined:
    Jan 12, 2013
    Posts:
    53
    Hi, I'm trying to figure out whether it's possible and how to achieve the following using UNet/ (any other middleware in store):

    Basically I'd like the server to be authoritative (independent from players), where it holds the important and sensitive player data such as the player's stats, health etc... That's fine and all but what I don't know how or if it's possible to do with the current available technologies is to have players themselves host lobbies of the game and become something like sub-hosts of a gamemode using peer to peer). For example Player A and Player B both connect to the server and get their stats from the main server. Than Player A decides to start a game of "Gamemode A". The main server marks Player A as a host and gives him "Gamemode A"'s data such as number of enemies that will spawn. Player B joins Player A's game and Player A's machine will take care of stuff like synching movements etc with p2p removing these calculations from the main authoritative server.

    I'm not asking for code on how to do this, what I'd like is to know if it's available in current technologies to achieve this network design without many changes.
     
  2. Dark_Tiger

    Dark_Tiger

    Joined:
    Oct 21, 2014
    Posts:
    32
    Short answer, yes, however it would defeat the purpose of having an authoritative server since you would have to have server code with the client. That would make the code vulnerable to hacking. If you want it to be 100% secure you have to run the server remotely from the players. But if you really want to remove stress from the main server then you could set hard limits that get checked at the end of the match, so if you have some sort of currency that players get from completing a mission then you'd want to make sure that the players haven't magically gotten more than they should. You could also store how much damage the players do and how fast they completed the match, if they're doing 9999999 damage or completing in less than a second then that should raise some red flags.
     
  3. GD-Darren

    GD-Darren

    Joined:
    Jan 12, 2013
    Posts:
    53
    Thanks for your reply. I understand it's highly insecure and I already have some measure sin place to prevent some issues.

    May I ask how one would go around doing this (having a main server connection and a p2p player host connection at the same time) and with what technology (uNet? Photon?)? Thanks in advance.
     
  4. Dark_Tiger

    Dark_Tiger

    Joined:
    Oct 21, 2014
    Posts:
    32
    That's a bit tough to answer since the implementation is entirely dependent on your needs, you would want to be able to set up the match. So you could send the clients IP and the port that the client will be listening on, to the server, so when another client selects the match to join they just get the hosts IP and port from the main server and then connect to the player that's hosting the match, then you just go about your business like you would. Depending on what you use there should be a variation of SendRPCToIP which you could use to communicate with the hos.

    I haven't looked at many different networking solutions, only very briefly, Photon, and more recently Dark Rift. If I remember correctly however Photon is set up to create rooms with ease, but this room creation happens on the server so you'd have to do some digging and see if you can ping the client with a command to set up the room there and then ping back to the main server to say that the room is available for people to join.