- Home /
I have this script here for multi player and I cant seem to find the compiler errors.
This is the script im using.
using UnityEngine;
using System.Collections;
/// /// Multiplayerscript. This script is attached to the MultiplayerManager and it /// is the foundation to our multiplayer system. ///
public class Multiplayerscript : MonoBehaviour {
//variables start___________________________________
private string TitleMessage = "GTGD Series 1 Prototype";
private string ConnectToIP = "127.0.0.1";
private int connectionPort = 26500;
private bool useNAT = false;
private string ipAdress;
private string port
private int numberOfPlayers = 10:
public string playerName;
public string severName;
public string serverNameForClient;
private bool iWantToSetupAServer = false;
private bool iWantToConnectToASever = false;
//these variables are use to define the main
//window.
private Rect connectionWindowRect;
private int connectionWindowWidth = 400;
private int connectionWindowHeight = 280;
private int buttonHeight = 60;
private int leftIndent;
private int topIndent;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
void connectWindow()int winowID
(
//Leave a gap from the header.
GUILayout.Space(15);
//When the player launches the game they have the option
//to create a server or join a server. The variables
//iWantToSetupAServer and iWantToConnectToAServer start as
//false so the player is presented with two buttons
//"Set up my server" and "connect to a server"
if(iWantToSetupAServer == false && iWantToConnectToASever == false)
{
if(GUILayout.Button("Set up a server", GUILayout.Height(buttonHeight)))
{
iWantToSetupAServer = true;
}
GUILayout.Space(10);
if(GUILayout.Button("connect To a server", GUILayout.Height(buttonHeight)))
{
iWantToConnectToASever = true;
}
GUILayout.Space(10);
if(Application.isWebPalyer == false && Application.isEditor == false
if(GUILayout.Button("Exit Prototype", GUILayout.Height(buttonHeight)))
{
Apllication.Quit();
}
}
}
void onGUI()
{
//If the player is disconnected then run the ConnectWindow function
if (Network.peerType == NetworkPeerType.Disconnected)
{
//Determine the position of the window based on the width and
//height of the screen. The window will be placed in the middle
//middle of the screen
leftIndent = Screen.width / 2 - connectionWindowWidth /2;
topIndent = Screen.height / 2 - connectionWindowHeight /2
connectionWindowRect = new Rect (leftIndent, topIndent,connectionWindowWidth,
ConnectionWindowHeight);
connectionWindowRect = GUILayout.Window(0, connectionWindowRect, ConnectWindow,
TitleMessage);
}
}
}
}
Yeah I wrote this but I was following this video.
http://www.youtube.com/watch?v=quxZ3DCtjuI&list=PLC90282759FD90F77
Their is 6 errors in this and they are: (16,15) parsing error, (12,16) name space, (10,14) name space, (8,13), (6,16) name space, (3,16) namespace.
The console doesn't say anything about line 56 being an error
Answer by robertbu · Feb 24, 2014 at 01:04 AM
Did you write this script? There is not just a single error here, but a number of them. To fix the errors, double click on the top error in the list in Unity and then go to Monodevelop. The error will be on the line it highlights or sometimes the line before. Fix that one error and then go back to Unity and get the new top error.
The first couple are simple errors, but you also have a larger messes on line 56. You are attempting to nest the 'connectWindow() function inside of Update() and have what I think is a variable declaration outside the body of the funciton. You cannot nest functions in C#
You need to go back and look at the structure of this code. Consider commenting out the contents of functions and then do what is necessary to get all the empty functions to compile. Then go back and worry about the contents.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I need Help with Multiplayer I can server but not use client 3 Answers
Unity networking tutorial? 6 Answers
setup a php master server 2 Answers