Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to test a multiplayer game using multiple machines?

Discussion in 'Multiplayer' started by BenjaminAlbrecht, Jun 27, 2019.

  1. BenjaminAlbrecht

    BenjaminAlbrecht

    Joined:
    Apr 27, 2019
    Posts:
    4
    I used UNet to create a very simple client-server application. The client sends a message to the server and the server responds. I successfully tested this by running the client and server on my local machine. I want to test this on multiple machines (i.e., run the server on one machine and run the client on another machine). What is the best way to do this?

    I know this is a bit of a dumb question, but I can't find any information online. Google is flooded with tutorials and forums about building multiplayer games or testing them on your local machine, but I can't find anything that answers my question.
     
  2. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Are all the machines on your local network? If so, start the server with it's local network IP address, and make all the clients point to it. Don't forget to ensure that the server has access through the firewall.
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You do it identical to running on the same machine. The only difference is on the client you provide the server's IP address instead of the loopback address, and you add the complexity of dealing with software firewalls. On Windows for example, the first time you run the server build you will be asked a question regarding the software firewall allowing networking connections to it. It is important you allow that, or you're going to have to later dig through the firewall settings and fix that before a client can access the server.

    If both computers aren't on the same local network, you will need to use port forwarding on the server's router, and the client will need to use the router's internet facing IP address.