I keep getting this error and me and my brother cannot figure out why its saying this. This is the error-
IndexOutOfRangeException: Array index is out of range.
(wrapper stelemref) object:stelemref (object,intptr,object)
BaseCharacter.SetupSkills () (at Assets/Scripts/Character Classes/BaseCharacter.cs:67)
BaseCharacter.Awake () (at Assets/Scripts/Character Classes/BaseCharacter.cs:26)
CharacterGenerator.Start () (at Assets/Scripts/Character Classes/CharacterGenerator.cs:11)
This is the Script-
using System;
public class CharacterGenerator : MonoBehaviour {
private PlayerCharacter _toon;
//Use this for initialization
void Start() {
_toon = new PlayerCharacter ();
_toon.Awake ();
}
//Update is called once per frame
void Update() {
}
void OnGUI() {
DisplayName ();
DisplayAttributes ();
DisplayVitals ();
DisplaySkills ();
}
private void DisplayName() {
GUI.Label (new Rect (10, 10, 50, 25), "Name:");
_toon.Name = GUI.TextArea (new Rect (65, 10, 100, 25), _toon.Name);
}
private void DisplayAttributes() {
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
GUI.Label (new Rect(10, 40 + (cnt * 25), 100, 25), ((AttributeName)cnt).ToString () );
GUI.Label (new Rect(115, 40 + (cnt * 25), 30, 25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());
}
}
private void DisplayVitals() {
for(int cnt = 0; cnt < Enum.GetValues (typeof(VitalName)).Length; cnt++) {
GUI.Label (new Rect(10, 40 + ((cnt + 7) * 25), 100, 25), ((VitalName)cnt).ToString ());
GUI.Label (new Rect(115, 40 + ((cnt + 7) * 25), 30, 25), _toon.GetVital(cnt).AdjustedBaseValue.ToString());
}
}
private void DisplaySkills(){
}
}
It says that its on line 41. Its trying to reference this script-
public class Vital : ModifiedStat
{
private int _curValue;
public Vital()
{
_curValue = 0;
ExpToLevel = 50;
LevelModifier = 1.1f;
}
public int CurValue
{
get
{
if(_curValue > AdjustedBaseValue)
_curValue = AdjustedBaseValue;
return _curValue;
}
set{ _curValue = value;}
}
}
public enum VitalName
{
Health,
Stamina,
Mana
}
Thanks!