Hello guys of course I checked google already and found a couple of usefull topics I understand why it freezes my game for the initial load. I’ve attempted at throwing yield at it but scince its a function it I get an error that says “You can’t evaluate void members” or something of the like. I found this thread http://forum.unity3d.com/threads/83946-Can-yield-be-used-within-a-ScriptObject where someone was trying something similar but its in Boo or C# and I’m more of a Javascript kind of guy so it would just be alot easier to stick with JS heres my script for reference.
import System.Xml;
//This script, adds and updates individual multiplayer users
///////////////////////////////////////////////////////////////////////////////////////////////////////
//Set variables
var multiplayerPrefab : Transform;
//Start script////////////////////////////////////
var lastUpdate;
function Awake(){
//Set starting variables
lastUpdate = Time.time;
}
function Update(){
//Get player list at least once a second
var timeRange = Time.time - lastUpdate;
if(timeRange > 1){
updatePlayers();
lastUpdate = Time.time;
}
}
function updatePlayers(){
//Get an update on player positions
//Read Player data and commence functions accordingly
var xmlData = new XmlDocument();
xmlData.Load("http://fleshvirus.com/fleshserver/loadPlayers.xml");
//Get number of players to loadPlayers
var numPlayers:float = int.Parse(xmlData.ChildNodes[0].Item["numPlayers"].InnerText);
//Get all nodes
var rootXml = xmlData.DocumentElement;
var ienum = rootXml.GetEnumerator();
while(ienum.MoveNext()){
print(ienum.Current.FirstChild.InnerText);
}
//Loop through all the player info; If they are not on the board load them up; If the players that are loaded are not on the list they logged off disconnect them;
//print(xmlData.ChildNodes[0].Item["playerdata"]["x"].InnerText);
}