- Home /
What does this error mean?
everything works except for the sounds and it still lets me play without um,the error is: IndexOutOfRangeException: Array index is out of range. Footsteps+$FootStepsSound$85+$.MoveNext () (at Assets/OG_Scripts/HUD Classes/Footsteps.js:14)
For this script:
var footAudio: AudioClip[]; var controller: CharacterController;
private var Run: Run = null;
function Awake(){ FootStepsSound(); }
function FootStepsSound(){ while(true){ if (controller.isGrounded && controller.velocity.magnitude > 3){ var volume = Mathf.Clamp01(Time.time); controller.audio.PlayOneShot(footAudio[Run.stepSound], volume); yield WaitForSeconds(Run.audioStepLength); } else { yield; } } }
I don't know what the error wants me to change, help would be appreciated
Please format your code! Noone can read unformatted code!!!
I sent a thank you comment a few $$anonymous$$utes ago, what you said helped, there were missing audioclips, I only put 2 there were supposed to be 5, Thanks XP
Answer by Benproductions1 · Mar 14, 2013 at 12:15 AM
Index out of range exception, means that you are trying to access something in a list of some sort that doesn't exit at that index.
probably controller.audo.PlayOneShot(footAudio[Run.stepSound], volume)
is trying to access footAudio[Run.stepSound]
does not exist , but it's hard to tell, since you don't format your code!!!
Hope this helps, Benproductions1
yeah,thats where the error took me but I didn't know what to do , I did set audioclips but anyway thanks for making this make a bit more sense
never$$anonymous$$d, thanks, what you said helped, I justed needed to add a few more clips, I had 2 it needed 5, Thanks XP
If I answered your question, please accept it as the answer, by clicking the little tick under the thumbs down button :)
Or close the question if you want
Answer by whebert · Mar 14, 2013 at 12:27 AM
The offending piece of code that appears to be causing this exception is the following:
footAudio[Run.stepSound]
It means that your Run.stepSound value, at the moment of the error, is higher than the amount of audio clips you have in your footAudio array. For instance, if you have 4 audio clips in the footAudio array, and your Run.stepSound is set to 4 or higher (should be between 0 and 3), you will get the IndexOutOfRangeException.