Categories
Video Games

Unity LAN and P2P Networking

Matrix World

I have spent the past month trying to make online connections work in a game of mine. It took me around one month just to get basic connections working, when in reality it should have taken me around one week. Read on to see what happened.

Here is some quick background information, I am using Unity and their built-in multiplayer networking solution, the online connections are either LAN (Local-Area Network) or P2P (Peer-to-Peer), and Steam is hosting the lobby information.

The issue I ran into was that I couldn’t connect to other clients, even on LAN. I first thought this was a router issue by not accepting internet traffic from other clients. I tried to resolve this by configuring my router to forward port 17778 to my computer’s internal IP address (you don’t have to use port 17778). This didn’t solve it. I tried changing the port, the computer on which the game was running on, and even tried connecting to another computer on my LAN via their public IP address. No luck.

After nearly giving up and reading dozens of forums, I came across someone else who was having this issue. But he was using Unity’s multiplayer service (external service offered by Unity that allows you to use their matchmaker and relay servers). I thought this doesn’t apply to me, but I checked regardless in my project settings. Turned out, I was using Unity’s multiplayer service. The project I was working on now was built on top of a project that was using Unity’s multiplayer service. That meant that this game was using it as well. I turned off the multiplayer service, tried the networking again, and it worked fine.

Long story short; make sure your game is not built on top of another project, and if it is, make sure you are not using something that you don’t need.

Leave a Reply

Your email address will not be published. Required fields are marked *