[Networking] direclty connect player without using untiy matchmaker

Hello, sorry if it’s not on the right section.

I have start develop a multiplayer game with 8 players per game. I can’t pay for unity’s matchmaker services so i want to create a button that start a server on the client, then pass his ip and port to a txt files stocked on a server then each player can join him with Network.Connect
I know how to connect player and how to use the network manager but i don’t know how to make client start hosting and allow other computer to connect to him. I have made some research on internet and i have understand that i need to do “port forward” but i don’t really know how and what is it.

Thank for reading this, sorry for my bad english.

Port forwarding is something you do in your router to tell the “outside” world that a certain internal ip address (and port) should receive (types) of incoming data.
If you had 3 computers and wanted 1 to receive the game, you’d forward the port and that PC’s ip address in the router, so when you play the traffic goes there. It’s pretty easy once you find it in the router config panel :slight_smile:

As for setting up the connections, if you already know how to do that, as far as I know - whenever I’ve done this - I have to tell anyone connecting what the ip address is. There’s no way for a host to tell other people automatically.

There is also UPNP for routers, and I do not know how to do it personally, but I know you can write something for that, probably beyond the scope here :slight_smile:

I’m not sure whether the matchmaking service has to be paid during development / for a small amount of players, but I believe you can use the 20 CCU for testing purposes. So if you only need to test atm, you should be fine using that.

Alternatives:

If you want to provide a comfortable solution, you’d probably either go for

  • hole punching
  • 3rd party/custom “relay” server implementation

If you want to be less user-friendly, you’d go for port forwarding or a 3rd party tool that kind of creates a “network” that all clients can be a part of, as if they were connected within the same LAN + subnet.

Im only student so i can’t pay for unity’s relay/matchmaker. I will try hole punching but i don’t know how. I only need to pass host ip and port to all player who want to join ? Or is it mire complicated ?

Just read it up.
But either way you’ll need some mechanism to share information about matches, basically some kind of service to query the matches which are available.

Still, somewhere I’ve read that you won’t need to pay for testing purposes and the website does also suggest it. I’m not completely sure whether this includes such services but you may just attempt to find out a little more about it.

I think @Suddoha 's suggestions are all decent.

I am curious, though, when you brought up being a student - is this a project for school or yourself?
Related (or not) – Do you need a lobby?

Reason for asking: If this is a school project, and you have to create a multiplayer game, but there’s no requirement for a lobby, the advice may differ. :slight_smile:

It’s a school project but we are free to do what we want. I want to make a lobby but i have already done this. I don’t want to use free unity matchmaker because the live mode is paid only. I think i will query match info in a sql database. I will test this tomorrow.

Thank you for your help.

Okay, good luck… hope it goes well :slight_smile:

Okay, it’s take more time than what i was thinking but anyway, this work localy (whis 2 computer on the same network) but this doesn’t work if anyone is not on the same network. I have check on http://www.canyouseeme.org/ and the port is not forwared. I don’t know if it’s normal. How can i allow peaples to host game and other join them ?

In order for two people to connect to each other without an intermediate server you have to either open the port manually or handle NAT punchthrough in your application. Typically NAT punch requires servers somewhere but I think there is some asset on the store that handles it automagically.

I have found this asset (https://www.assetstore.unity3d.com/en/#!/content/58948) but it’s quite expensive for me because i’m a student. Other possibilities exist or i need to pay this?

I’m still watching this thread. It’s a project and you want to get it to work. Just enable port forwarding and continue with your work :slight_smile: That’s by far the simplest solution.

1 Like

This is the answer. Open it manually with zero hassle or deal with NAT punchthrough.

i want to make the apps easy to use for everyone so i don’t want to use port forwarding manualy

Then you have to add automatic NAT punchthrough.

Yes, i know that the question was how to do that? There is a free way or a cheep way? Or i need to pay this asset a 45$ ?

If it’s just for a school project then why is this an issue? You get 20 concurrent users for free.

It’s a school project but i want to make it a real game that we can play with friends. Either the unity relay don’t allow real time networking without paying. Thanks for your reply, i will buy the asset.

Where did you get that impression?

I’m only pushing the point because if you do your own networking you’re going to have to write a ton of boilerplate code just to get off the ground. Why do that when you can use what’s integrated into the engine already?

In the services multiplayer menu, it’s set to turn to turn by default and for the “live mode”, you need to pay.