Testing Multiplayer

There are three different ways to test the multiplayer gameplay.

  • Peer 2 peer

  • Dedicated Server

  • Unity Services

It is suggested to use the dedicated server or unity services for multiplayer, as peer 2 peer comes with more limited features (lobby system is not available in P2P) and because players won't need to setup their firewall and router for port forwarding.

Peer to Peer

To test in peer to peer, build the game and in the menu click on Multiplayer LAN.

You will be asked to join or host, and will be able to join someone else. You can simply run the build twice on the same pc, so that you can play with both players.

You can also open the Unity project twice instead of doing a build. (See at the bottom of this page)

Dedicated Server

You can either run the dedicated server locally or run it on a cloud server. To run it on the cloud, see the page Cloud Server Installation.

To run it locally. Make a build with only 1 scene: Server

You can also check the box "Server Build" to disable all graphics from the build.

Go in Resources/NetworkData, and change the game server url to the IP or url of your dedicated server (if you run it locally put 127.0.0.1).

You can run the server build, and then connect to it from Unity or from a Client build. Client build should include the menu and game scenes.

In the client menu, click on Multiplayer Lobby. If it shows "Connecting to server..." this means it can't connect to it. If it loads the list of rooms (there may be none), you successfully connected to your server.

Client Build

Server Build

Unity Services

You will not need a server build if you use Unity Services. Only a client build (same as above).

More Information in the Unity Services page.

Opening the Unity Project Twice

Opening the unity project twice can save you some build time if you want to quickly be able to test two clients, or one client and one dedicated server, directly from Unity instead of having to make a build each time.

Check this tutorial (it is for one of my other assets) to learn how to open the same unity project twice: https://indiemarc.gitbook.io/netcodeplus/getting-started/testing-locally

Last updated