Hello, i am following a Tutorial Series (Aggregat Games) and i typed exactly how they did it but i get these two errors:
First Error: Assets/Scripts/NetworkManager.cs(39,80): error CS0103: The name `OnlinePlayer’ does not exist in the current context
2nd Error: Assets/Scripts/NetworkManager.cs(64,22): error CS1061: Type Player' does not contain a definition for
PlayerName’ and no extension method PlayerName' of type
Player’ could be found (are you missing a using directive or an assembly reference?)
Here is the complete Code (btw it´s in C#):
public string MatchName;
public static NetworkManager Instance;
public List<Player> PlayerList = new List<Player>();
public Player MyPlayer;
// Use this for initialization
void Start ()
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
// Update is called once per frame
void Update ()
{
PlayerName = PlayerPrefs.GetString("PlayerName");
}
public void StartServer(string ServerName, int MaxPlayers)
{
Network.InitializeSecurity();
Network.InitializeServer(MaxPlayers,25565,true);
MasterServer.RegisterHost("Bulletrain",ServerName,"");
Debug.Log ("Started Server!");
}
void OnPlayerConnected(NetworkPlayer id)
{
//networkView.RPC("Server_PlayerJoined",RPCMode.Server, PlayerName, id);
foreach(Player pl in PlayerList)
{
networkView.RPC("Client_PlayerJoined", id, PlayerName, OnlinePlayer);
}
}
void OnServerInitialized()
{
Server_PlayerJoined(PlayerName, Network.player);
}
void OnConnectedToServer()
{
networkView.RPC ("Server_PlayerJoined", RPCMode.All,PlayerName, Network.player);
}
[RPC]
public void Server_PlayerJoined(string Username,NetworkPlayer id)
{
networkView.RPC ("Client_PlayerJoined", RPCMode.All,Username, id);
}
[RPC]
public void Client_PlayerJoined(string Username,NetworkPlayer id)
{
Player temp = new Player();
temp.PlayerName = Username;
temp.OnlinePlayer = id;
PlayerList.Add(temp);
if(Network.player == id)
{
MyPlayer = temp;
}
}
//void OnPlayerConnected(NetworkPlayer id)
//{
//Player temp = newPlayer();
//temp.PlayerName = PlayerName;
//temp.OnlinePlayer = id;
//PlayerList.Add(temp);
//}
}
[System.Serializable]
public class Player{
public string PlayeName;
public NetworkPlayer OnlinePlayer;
}
I would be very thankful if someone could correct my Code