- Home /
Question by
daley_cousins · Dec 03, 2013 at 10:03 PM ·
arrayindexindexoutofrangeexception
IndexOutOfRangeException: Array index is out of range.
i have a big problem.. i am scripting the networking for my online game, and i stutterd op to this bug. this is the NetworkManager script. but my player can't spawn because of this anoying bug:
void OnGUI() { if(MatchStarted == true && !MyPlayer.IsAlive) { if(GUI.Button(new Rect(0,0,50,20),"Spawn")) {
int SpawnIndex = Random.Range(0, LevelManager.ins.SpawnPoints.Length -1);
ERROR>>>>>> MyPlayer.Manager.FirstPerson.localPosition = LevelManager.ins.SpawnPoints[SpawnIndex].transform.position;
MyPlayer.Manager.FirstPerson.localRotation = LevelManager.ins.SpawnPoints[SpawnIndex].transform.rotation;
MyPlayer.Manager.networkView.RPC("Spawn",RPCMode.All);
}
}
}
}
can someone help finding the bug i have?? thank you
ps the error is on the lane where "error>>>>>" stands
Comment
Have you checked the length of the SpawnPoints array?