From LAN ... To WAN (or MAN)

Hi, I am looking forhelp, again. I found a unity3d networking tutorial;) and made a working game… on LAN. Now, for the experiance of other users, and for my game, does anyone know anything about making network wireless(WAN).

As far as I know, this might require a physical server.
Thank you all so much for your help.

that depends on your server/client setup. do you use a masterserver or a middleware like photon or smartfox ?

for unity networking it makes no difference through what kind of “AN” you are connected, all that ocunts for it is that there is UDP communication that can be established :slight_smile:

What? wow? I just have a connection code I got from the unity website. I thought the Wireless connection would just be connecting to a server, no?

any kind of connection you do will be to a “server”. With server I mean another unity client that initializes the server.
Thats what you do on LAN and thats what you do on any other kind of connection

Here I go sounding dumb:

So all I have to do is start a server (script comes with function intellizes server and what not) and then I can connect to it from another computer? I thought 127.0.0.1 was your computer only. Should masterserver.unity3d.com be sufficient for wireless?

Ok I see that it 2 ways :

  1. I have all players connect to a website server ex: 230.92.0.2 (not real)
  2. I have a player start a server and people connect to him from different computers. (would 127.0.0.1 work for this?)

These options I listed are just theories. Do they work, ill try. But i’d apretiate it if someone could help me figure out how to make this work.

Zu01,

I think that lack of concrete help you’ve received so far is because it is unclear what networking options you are trying to use. The answer depends on that.

For example, if you were using ElectroServer as the server that routes messages between players, then that will need to be installed in a remote location that clients can access, for example electrotank.com. Each client would specify electrotank.com as the host, and then whatever port was used (say, 9899) as the port.

If you are using Unity’s built-in networking code then things are a bit different. I don’t know the answer for this well enough to provide advice. But if this is what you are doing then I’m sure someone else can help.

I’m sorry for my lack of information. I just learned about networking and I am frankly lucky to have these codes and know some-what-a-thing about this. I don’t know what UDP is or anything. From what you wrote I understand that you need something like elctro server set up on a domain wich then people connect to. Is that right?

Zu01,

It sounds like you would benefit greatly from some reading some introductory tutorials. There are a bunch that center around Unity. And my latest book focuses on mutliplayer games, but it uses Flash as the client (not Unity).

But to answer your question: yes.

Yes I would, so far I found the Zero to hero guide, it helped woth scripting. I just basiclly copied the stuff of the unity one, wich has no documentation.

Do you need a website? I was gonna buy one from bluevoda for $98. How to you use electro server?
BTW, this is the networking script I use:

//DontDestroyOnLoad(this);
var remoteIP = “127.0.0.1”;
static var Name = “Name”;
var remotePort = 25001;
var listenPort = 25000;
var useNAT = false;

function Awake()
{
if (FindObjectOfType(ConnectGuiMasterServer))
this.enabled = false;
}

function OnGUI ()
{
GUILayout.Space(10);

GUILayout.BeginHorizontal();
GUILayout.Space(10);
if (Network.peerType == NetworkPeerType.Disconnected)
{
GUILayout.BeginVertical();
if (GUILayout.Button (“Connect”))
{
Network.useNat = useNAT;
Network.Connect(remoteIP, remotePort);
}
if (GUILayout.Button (“Start Server”))
{
Network.useNat = useNAT;
Network.InitializeServer(32, listenPort);
// Notify our objects that the level and the network is ready
for (var go in FindObjectsOfType(GameObject))
go.SendMessage(“OnNetworkLoadedLevel”, SendMessageOptions.DontRequireReceiver);
}
GUILayout.EndVertical();
remoteIP = GUILayout.TextField(remoteIP, GUILayout.MinWidth(100));
remotePort = parseInt(GUILayout.TextField(remotePort.ToString()));
Name = GUILayout.TextField(Name, GUILayout.MinWidth(100));
}
else
{
if (GUILayout.Button (“Disconnect”))
{
Network.Disconnect(200);
}
}

GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}

function OnConnectedToServer() {
// Notify our objects that the level and the network is ready
for (var go in FindObjectsOfType(GameObject))
go.SendMessage(“OnNetworkLoadedLevel”, SendMessageOptions.DontRequireReceiver);
}

function OnDisconnectedFromServer () {
if (this.enabled != false)
Application.LoadLevel(Application.loadedLevel);
else
FindObjectOfType(NetworkLevelLoad).OnDisconnectedFromServer();
}

P.S. - Merry Christmas
P.P.S. - Some of the stuff here is set up for my prefrance, so the name and NetworkLoad stuff requires different scripts.

I begun watching your electroserver tutorials. But Thrift.dll has an error when ever I add it to my project. Any protocol for this?

Zu01,

What kind of an error? I’ve not experienced any error during adding a DLL to a project.

If you downloaded ElectroServer, there should already be some Unity examples that have the right DLLs included.

127.0.0.1 is your loopback address, so if you were to start a game and create a server, the only place you could connect to that game by connecting to 127.0.0.1 would be from that same computer (eg: launching another game from a webplayer, and connecting to the game that you started hosting in the Unity editor).

However, if you have a LAN at your house (wireless or ethernet, doesn’t matter), when you host a game on one computer, the IP address to that game over the network will be your network ip address (not 127.0.0.1). You can get your network ip address by running ipconfig from command prompt in windows. Once you have that, you can launch a game client from another computer on your network and connecting to it.

legend411, didn’t have time to try that tonight. But that seems like it could be right. I got 2 ip’s. 192.168.1.1 and 192.168.1.2, I get don’t know which one. But I know I will test it tomorrow

192.168.1.1 would be rather non standard cause thats normally the router adress if the systems get 192.168.1.x as their IP. (generally its always the one ending on 1 with the first 3 tripplets equal to yours where you find the router)

So it is most likely 192.168.1.2, I went to my friends house and typed ipconfig. I got 192.178.1.102, we both tried to use that one, and it worked!