Not sure what's wrong here...

Hi, today i tried to make a simple scene that would use networking, and i didnt get very far on it because im not sure of a few things:

Do i need a master server like SmartFox no matter what i do (dedicated server, etc)?

also here’s the scripts ive written and im not sure if they are written correctly or not, but i keep getting the error: The connection request to [IP : Port] failed. Are you sure the server can be connected to? and i really don’t know what the problem is here…

This is for the player prefab that is the LocalPlayer and starts the server.

function Awake () {
	
	var useNat = !Network.HavePublicAddress(); // I don't know if i need his line or not.. 
	Network.InitializeServer(32, 3233, useNat);
}

This is attached to the RemotePlayer

function Awake () {

	Network.Connect("IP", 3233);
}

And this script instantiates the remote and local player prefabs

var LocalPlayer : GameObject;
var RemotePlayer : GameObject;


function Update () {

	if (Input.GetKey("l")) {
		Instantiate (LocalPlayer, transform.position, transform.rotation);
		}
		
	if (Input.GetKey("r")) {
		Network.Instantiate (RemotePlayer, transform.position, transform.rotation, 0);
		}
}

Again, im not good at this stuff so if you see anything wrong with anything on here (i’m almost positive there is a lot wrong with it) please tell me :slight_smile:

Our basic free course about multiplayer can help you:
http://www.dmu.com

Hi ,

You need to fill in an existing IP adress :

function Awake () {

	Network.Connect("127.0.0.1", 3233);
}

This should work , if your server is running on the same machine as the client does.

@adamascj : Nice tutorial series, but sadly they are spanish only …


oxl

OXL,
Our multiplayer tutorials serie has an english version:
http://www.dmu.com
At the right side of the homepage

Ooops, how could I miss that ?

Thanks !


oxl