Search Unity

Multiplayer without using any Multiplayer Service Provider?

Discussion in 'Multiplayer' started by zesontay, Jun 20, 2018.

  1. zesontay

    zesontay

    Joined:
    May 6, 2018
    Posts:
    2
    Hi,

    I apologize in advance if this thread already has similar previous threads or that my question is too noob.

    I am currently designing a racing game and its main intention is to allow the match making among friends for a short race :) because of that, i believe that it is possible to make it such that one player will serve as the host and the others will be the clients.

    As such, i was wondering:
    1. Do i still need to enable the multiplayer services from unity?
    2. Will there still be charges for unity multiplayer given that i'm not using their servers (i believe?) and i'm just using one player as host?

    I wanted to create a small racing game for friends to play with each other and i'm hoping to not incur multiplayer cost if possible. If having one player host the game will still incur cost, may i ask what are my methods that i can consider? I have been looking around for information but cant seem to find ways of implementing this. :(

    However, i was thinking that this manual will point me in the right direction?
    https://docs.unity3d.com/Manual/UNetClientServer.html
     
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    The costs come in when you use Unity's relays as part of the multiplayer services. If you have a player host and you connect directly you don't need the relays or multiplayer services at all.

    The thing is though, you need some sort of matchmaking, otherwise, how does the client get the host's IP to connect to? Luckily the matchmaking itself is actually free. So you can hook your project up to the multiplayer services for the matchmaking and just make sure to join directly and not over the relays.

    Ok cool, but now here's the real problem. Hosts that are behind a router are often not going to be connectable due to NAT issues (google NAT for more info). This is why relays are a thing to begin with, so that peers can host even though they can't be directly connected to.

    I've got two solutions for you that will get you part way there, but even with both you will still need relays to guarantee that every host can be connected to.

    1. NAT Traversal - This is a bit of magic that punches holes through routers and does automatic port forwarding so that players actually can host from behind a router (mostly). Unfortunately this only works something like 85-95% of the time because some routers can't be punched through. So you still need relays to fall back on to guarantee a connection every time. It will save you a ton of money vs using the relays all of the time though.
    2. Match Up - An alternative to Unity's matchmaking for if you really want to avoid the multiplayer services entirely.

    What it comes down to is this: If you want to guarantee any player can be a host, you're going to have to pay for some bandwidth. If you're ok with some players not being able to host then you can avoid all bandwidth costs. Either way I would recommend NAT Traversal to decrease bandwidth costs / improve direct connection rate.
     
    Last edited: Jun 20, 2018
    zesontay likes this.
  3. zesontay

    zesontay

    Joined:
    May 6, 2018
    Posts:
    2
    Thank you for the reply! It is really helpful info! I'll definitely have a look at the NAT Traversal and Match Up! :) They look like very worth while investments!