Search Unity

Regarding matchmaking and internet matches

Discussion in 'Multiplayer' started by Bmandk, Jul 9, 2015.

  1. Bmandk

    Bmandk

    Joined:
    Aug 18, 2012
    Posts:
    70
    So, I just tried out the Unity Multiplayer features, saw the Unite 2014 presentation, researched and tried it out for myself.

    I was actually working on a multiplayer game using the legacy system before this was released, so I have an idea for a game, as well as an understanding of the multiplayer. I figured I'd just start implementing the new networking.

    But I'm a bit confused. With the legacy networking, we had the MasterServer service, to list the servers and not much else. Here, we have the MatchMaker I think? That will require Unity Pro in the future, and only allows 100 CCU right now. With the legacy networking, it didn't seem like these limitations were present. So what I'm really asking for, is it possible to make internet games without the limitations of the MatchMaker? I'm going with "client as host"-design, which has a client as the host (Both server and client), which would seem to fit perfectly with the old MasterServer system, where it wasn't relayed anywhere first.
     
  2. Zephilinox

    Zephilinox

    Joined:
    Sep 15, 2014
    Posts:
    14
    You can use any server for MatchMaking, you will only need to pay if you want to have Unity host it for you (as far as I know)

    You don't need to use any matchmaking though, you can simply have one player as the host (client+server) and the other connect directly to the hosts IP. Add the NetworkManagerHUD component to see an example.

    in 5.2 there will also be LAN broadcasting for the HLAPI, although you can already do this with the LLAPI.
     
  3. Bmandk

    Bmandk

    Joined:
    Aug 18, 2012
    Posts:
    70
    Well, seems to me that the NetworkManagerHUD uses the matchmaker for internet games? Either that, or only LAN.

    How would I go about connecting directly to an IP?
     
  4. Zephilinox

    Zephilinox

    Joined:
    Sep 15, 2014
    Posts:
    14
    simply replace "localhost" with the IP Address in the HUD when you launch the application.

    You can find the HUD source code here, if you're interested: http://forum.unity3d.com/threads/networkmanagerhud-source.333482/
     
  5. Bmandk

    Bmandk

    Joined:
    Aug 18, 2012
    Posts:
    70
    Ah great, thanks.

    Another question, unrelated to the matchmaking: I'm trying to spawn a spell (with networking), which is just a GameObject. The spell is spawned right in front of the player. But since the server is the one that handles spawning, it also uses the server's position and rotation at the time of spawning, instead of the client's. This means that it will not spawn in front of the player on the client, but rather on the server which makes the position and rotation quite funky.

    I tried passing the client's position and rotation to the Command function, but it would use the server's variables instead of actually sending the client's. Is it possible to fix this somehow, so it will use the client's variables?
     
  6. Zephilinox

    Zephilinox

    Joined:
    Sep 15, 2014
    Posts:
    14
    That's just how network lag works. If you have 1 second ping then if the client is moving when he sends a command to the server to spawn a spell, the spell on the server will be spawned where the player on the client was 0.5 seconds ago, then be sent to the client where the client would have been moving for another 0.5 seconds.

    What you could do is spawn the spell on the client and the server and lerp the client spell position to the position of it on the server, but it probably won't look too great as there will be lots of jumping when the position tries to correct itself.

    You might be able to learn some more about it from reading this (http://www.gabrielgambetta.com/fpm1.html), but generally it's pretty tricky to solve in a way that looks good, at least from my understanding.

    Alternatively you could just ignore what is happening on the server and simulate it on the client, the server will update the other players with your spell, and you can just let the client simulate the spell itself. The result of the spell on the server and the spell on the client should be similar enough (just delayed), and when it's not the server will have authority over the actual game anyway.
     
  7. Bmandk

    Bmandk

    Joined:
    Aug 18, 2012
    Posts:
    70
    Okay, I think I've got what I wanted, everything runs pretty smoothly.

    Although, now I'm back at the hosting. With legacy, I was able to use MasterServer to list the different games and connect to the games. As far as I can see, the only close equivalent is the MatchMaking system, and I would like to avoid that considering the need for pro later and only having 100 CCU. Would I need my own MasterServer to register the different games made? Or does the new networking have something like the old MasterServer without the need of a relay and MatchMaking service?
     
  8. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I suppose you could actually use the old master server somehow lol... I haven't tried but its a thought
     
  9. Bmandk

    Bmandk

    Joined:
    Aug 18, 2012
    Posts:
    70
    So if I don't use the MatchMaking service, I have to use either the old MasterServer service (which I'm guessing they're going to remove) or make my own, and still have the need for a host?

    It was a really, really good feature as you didn't have a relay, but was able to just have a list of the different games created.
     
  10. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Again I have never tried doing that, but maybe it is possible for it to track IP's and hosts and what not for your, so you can do the whole client-server thing using uNet, and ask it for the servers that are up. I don't know if they plan to stop supporting the master server anytime soon...