Skip to content

Setting Up Client & Host

Ryan edited this page Jun 20, 2020 · 1 revision

I have made sure setting up a client/host is easier than ever!

Host Setup

First you must create a NetServer variable:

public NetServer server;

Then all you have to do is initialize the server, then start the server. Like so. ` server.Initialize();

server.StartServer(); `

I recommend making server a public variable so you can easily edit it within the Unity editor.

Client Setup

Setting up the client is as easy as the host. Simply create a NetClient variable:

public NetClient client;

Then all you have to do is initialize it, then connect to a server.

  • client.Initialize()

  • client.ConnectToServer(ip,port);

  • You can disconnect by using client.DisconnectFromServer();

Notes

  1. With both the NetClient/NetServer I highly suggest making them public variables, and editing them within the Unity editor.

  2. Make sure "NetworkData" exists and is attached to a GameObject somewhere. It is needed for Instantiating prefabs.

Clone this wiki locally