Can't see each other!

Hello. So, when I use my code to start a server, and then connect to a server, I know that both screens are connected to the same server because I have a GUILayout.Label("Connections: " + Network.connections.length); which always goes to 1 when the client connects. Now my problem is I can’t see the other player, even though we are on the same network. Can someone take a look at my code please and tell me what I’m doing wrong, because I looked up for some tutorials and they are all confusing. Thanks in advance! Also, I port forwarded the port to the IP address so the IP address and port aren’t the problem. I know the code is very messy, but thats what I get for using around 5 tutorials in one code. :confused:

#pragma strict
#pragma implicit
#pragma downcast

var connectToIP : String = "192.168.1.xxx";
var connectPort : int = 23466;
var Player : GameObject;
var avatar0 : Transform;
var loggedin : boolean = false;
var velocity = 5.0;
var velJump = 8.0;
var gravity = 20.0;
private var deltaDirection : Vector3;
var contr : CharacterController;
var playerClone : String;


//Obviously the GUI is for both client&servers (mixed!)
function OnGUI ()
{
	if(loggedin == false)
	{
		if (Network.peerType == NetworkPeerType.Disconnected)
		{
	//We are currently disconnected: Not a client or host
		GUILayout.Label("Connection status: Disconnected");
		GUILayout.BeginVertical();
			if (GUILayout.Button ("Start a Server"))
			{
			//Connect to the "connectToIP" and "connectPort" as entered via the GUI
			//Ignore the NAT for now
			Network.useNat = false;
			Network.InitializeServer(32, connectPort);
			loggedin = true;
			}
			if(GUILayout.Button("Connect as client"))
			{
			Network.useNat = false;
			Network.Connect(connectToIP, connectPort);
			loggedin = true;
			}
			GUILayout.EndVertical();
		}
	}
	if(loggedin == true)
	{ 
		if(Network.peerType == NetworkPeerType.Client)
		{
		GUILayout.Label("Connection status: Client!");
		GUILayout.Label("Ping to server: "+Network.GetAveragePing(  Network.connections[0] ) );	
		GUILayout.Label("Connections: " + Network.connections.length);
		Application.LoadLevel("game");
		} 
		else 
		if (Network.peerType == NetworkPeerType.Server)
		{
			
			GUILayout.Label("Connection status: Server!");
			GUILayout.Label("Connections: "+Network.connections.length);
			GUILayout.Label("Connections: " + Network.connections.length);
			Application.LoadLevel("game");
		}
	}
		
}
function OnLoaded()
{
	Network.Instantiate(avatar0, transform.position, transform.rotation, 0);
	playerClone = "3rd Person Controller(Clone)";
	Player = GameObject.Find(playerClone);
	contr = Player.GetComponent(CharacterController);
}
function Update(){
  if(!Player) return;
 if (contr.isGrounded){
   Player.transform.eulerAngles.y += Input.GetAxis("Horizontal");  
   deltaDirection = Vector3(0, 0,Input.GetAxis("Vertical"));
   deltaDirection = Player.transform.TransformDirection(deltaDirection);
   deltaDirection *= velocity;
 }

  deltaDirection.y -= gravity * Time.deltaTime;
  contr.Move(deltaDirection * Time.deltaTime); 
}

function OnPlayerDisconnected (player : NetworkPlayer){
 Network.RemoveRPCs(player, 0);
 Network.DestroyPlayerObjects(player);
}

The ‘loggedin’ boolean is set after the connect call, you can use callbacks for that.
OnLoaded is never called. → Objects won’t appear in the scene.
Also the code in OnLoaded is messy.
You can cast the instantiate to a GameObject and get the CharacterController and drop the find call.
I wouldn’t handle the character controller in the same script. Create a new one and attach it to the object.

Thanks for responding! So I edited the code to my understand, and now when I host the game, and then the client connects, the host starts seeing 2 copies of players, one which is the client and one I have no idea where it came from. The host then gets redirected to an empty part of the game with the player which just came randomly, and they start falling. Why is the host seeing 2 people instead of 1? Where is the extra clone coming from? Also why does the host get redirected on the map? Also, when I try adding more than 1 client, the clients can’t see each other. Why can’t they? Sorry if I’m asking for too much. :S Here is my code if you need it:
EDIT: The host ends up controlling 2 people, one of which is a random person, and he doesnt see the client nor does the client see the host or the random person.

#pragma strict
#pragma implicit
#pragma downcast

var connectToIP : String = "192.168.1.xxx";
var connectPort : int = 23466;
var Player : GameObject;
var avatar0 : Transform;
var loggedin : boolean = false;
var contr : CharacterController;
var playerClone : String;


//Obviously the GUI is for both client&servers (mixed!)
function OnGUI ()
{
	if(loggedin == false)
	{
		if (Network.peerType == NetworkPeerType.Disconnected)
		{
	//We are currently disconnected: Not a client or host
		GUILayout.Label("Connection status: Disconnected");
		GUILayout.BeginVertical();
			if (GUILayout.Button ("Start a Server"))
			{
			//Connect to the "connectToIP" and "connectPort" as entered via the GUI
			//Ignore the NAT for now
			Network.useNat = false;
			Network.InitializeServer(32, connectPort);
			loggedin = true;
			}
			if(GUILayout.Button("Connect as client"))
			{
			Network.useNat = false;
			Network.Connect(connectToIP, connectPort);
			loggedin = true;
			}
			GUILayout.EndVertical();
		}
	}
	if(loggedin == true)
	{ 
		if(Network.peerType == NetworkPeerType.Client)
		{
		GUILayout.Label("Connection status: Client!");
		GUILayout.Label("Ping to server: "+Network.GetAveragePing(  Network.connections[0] ) );	
		GUILayout.Label("Connections: " + Network.connections.length);
		Application.LoadLevel("game");
		OnLoaded();
		} 
		else 
		if (Network.peerType == NetworkPeerType.Server)
		{
			
			GUILayout.Label("Connection status: Server!");
			GUILayout.Label("Connections: "+Network.connections.length);
			GUILayout.Label("Connections: " + Network.connections.length);
			Application.LoadLevel("game");
		}
	}
		
}
function OnLoaded()
{
	Network.Instantiate(avatar0, transform.position, transform.rotation, 0);
	playerClone = "3rd Person Controller(Clone)";
	Player = GameObject.Find(playerClone);
	contr = Player.GetComponent(CharacterController);
}

function OnPlayerDisconnected (player : NetworkPlayer){
 Network.RemoveRPCs(player, 0);
 Network.DestroyPlayerObjects(player);
}

You are calling the OnLoaded method about a 100 times a second in the OnGUI method. So that’s really bad. Same goes for the Application.LoadLevel(“game”);
When loading new scenes while connected to a server, you also need to prevent sending data to that client or it will get lost.
How are you sending movement data over the wire ?
I also have no idea why you are using the loggedin boolean, not needed since you are using Network.peerType which is the same thing.
You are complicating things a bit and still only using one callback : OnPlayerDisconnected
They were added to make things easier.