I posted this in the forum but this I think gets a quicker feedback sooo:
So I am using the old M2H tutorial script from way back when and they Network.Instantiate the characters through a for loop:
if(Network.isServer){
chatScript.ShowChatWindow();
//networkView.RPC ("TellOurName", RPCMode.AllBuffered, playerName, playerTeam);
for (var go : GameObject in FindObjectsOfType(GameObject)){
go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
}
MasterServer.RegisterHost(gameName, PlayerPrefs.GetString("playerName")+"'s game");
}else if(Network.isClient){
networkView.RPC ("TellOurName", RPCMode.AllBuffered, playerName, playerTeam);
chatScript.ShowChatWindow();
for (var go : GameObject in FindObjectsOfType(GameObject)){
go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
}
Then that goes down and on the OnNetworkLoadedLevel will randomly pick spawn point and then instantiate the player.
What it is doing though, is creating two for each player. This is messing my player up because i am switching camera views around during start up. and so the player screen just flashes i believe because it doesn't have the right camera to switch to or something.
Also I have tried getting rid of the for loop on the server side and have just the client's spawn up the player (i don't care right now if it authoritive or not) but it still creates two different characters of each, and they have the same name, just somehow one of them is turned off for the player so they don't notice anything.
any help on to why it is doing this and any easier fix? I have the players listed in an array from a class variable.
I have tried using for loop for the size of that array but don't know how to send a message then to each player that is in that loop cuz send message isn't a part of the playerlist array because it is a class variable.
unless I can do something like this?
for (var i = 0; i < playerList.length; i++) {
playerList[i].GetComponent(GameSetup).OnNetworkLoadedLevel();
}
I actually just see that it only makes two players each for all the other players but not the local player. Been trying to find a way to just atleast destroy it if I can't stop it from instantiating.
thanks for the input and help
↧