I have this error I cant solve

IndexOutOfRangeException: Index was outside the bounds of the array.
RPG.Stats.Progression.GetStat (RPG.Stats.Stat stat, RPG.Stats.CharacterClass characterClass, System.Int32 level) (at Assets/Scripts/Stats/Progression.cs:25)
RPG.Stats.BaseStats.GetLevel () (at Assets/Scripts/Stats/BaseStats.cs:30)
RPG.Stats.BaseStats.GetStat (RPG.Stats.Stat stat) (at Assets/Scripts/Stats/BaseStats.cs:17)
RPG.Resources.Health.GetHealthPercentaje () (at Assets/Scripts/Resources/Health.cs:80)
RPG.Resources.HealthDisplay.Update () (at Assets/Scripts/Resources/HealthDisplay.cs:20)

1 Like

I solved it!

Always be sure to let us know what the solution was, as you never know when it can help another student with the same problem. It looks like, in this case, you might have been trying to test a level that wasn’t in your Progression.

The problem was that in the for loop in GetLevel() in BaseStats I initialized level = 0 instead of 1

2 Likes

This is a common error. It’s easy to forget that arrays and lists start at 0 instead of 1.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms