IndexOutOfRangeException: array index is out of range.

I have 3 types of footsteps in the array, and for some reason i get this error, and cant seem to find a sulotion… Please help

Debug.Log( m_FootstepsSounds.Length );
Debug.Log( n );

one of these 2 lines lines will help you see the error (I cant without more info)

The m_FootsetpSounds must be less than 2 in length.

If you have populated it in the inspector, are you sure you don’t have another object with this script on by mistake?

The max of Random.Range is inclusive. It should be Random.Range(1, m_FootstepsSounds.Length -1)

Hey guys…thanks for the replys, it helped me to find the solution, I made 3 tags , wood concrete and dirt, because i have not used dirt yet i forgot to add soundfiles to that one and that caused the error, its working now…Thanks anyways

Its only inclusive with floats
With ints like this, its exclusive at the top