- Home /
Question by
Wololo Plays · Jun 20, 2014 at 04:11 PM ·
errormultiplayerplayer
Error in the script
My server script, is giving error. Please explain step by step, because I am new here.
I'm Brazilian
#pragma strict
var Ip : String = "127.0.0.1";
var Porta : String = "25000";
var MaxPlayer : String = "2";
var Senha : String;
var Player : GameObject;
function Start () {
}
function OnGUI () {
GUILayout.BeginArea(Rect(Screen.width / 2 - 150,Screen.height / 2 - 200,300,400));
if(Network.peerType == NetworkPeerType.Disconnected){
GUILayout.Label("IP :");
Ip = GUILayout.TextField(Ip);
GUILayout.Label("Porta :");
Porta = GUILayout.TextField(Porta);
GUILayout.Label("Max Players :");
MaxPlayer = GUILayout.TextField(MaxPlayer);
GUILayout.Label("Senha :");
Senha = GUILayout.TextField(Senha);
if(GUILayout.Button("Criar Server")){
Criar(int.Parse(Porta),int.Parse(MaxPlayer),Senha);
}
if(GUILayout.Button("Conectar Server")){
Connect(Ip,int.Parse(Porta),Senha);
}
}
GUILayout.EndArea();
}
function Criar(port : int,max : int,senha : String){
Network.incomingPassword = senha;
Network.InitializeServer(max,port,false);
OnConnectedToServer();
}
function Connect(ip : String,port : int,senha : String){
Network.Connect(ip,port,senha);
}
function OnConnectedToServer(){
Network.Instantiate(Player,Vector3.zero + Vector3(Random.Range(-2,2),0,0),Quaternion.identity,0);
}
function OnPlayerDisconnected(player : NetworkPlayer){
Network.DestroyPlayerObjects(player);
Network.RemoveRPCs(player);
}
alt text
Comment
Look in the inspector- your Player prefab appears to have some missing scripts.
@tanoshimi +1
specifically look at the components in the inspector that just state (Script), there was a reference to a script(s) that are missing/deleted or the reference was lost somehow, either add them back or remove the component if no longer used
As the error stated, the $$anonymous$$ain Camera object has a missing script component. I recommend downloading this editor script, it is very helpful when trying to find out which scripts are missing, and reassign them.
If I send the project. You tidy for me? I'm in trouble today.