- Home /
AudioClip array not working
I have a problem with AudioClip arrays;
Here is my code:
public AudioClip[] shootSound;
void Update () {
if(Input.GetMouseButtonDown(0)) {
audio.clip = shootSound[0];
audio.Play();
}
}
Every time I press the button I get this message:
IndexOutOfRangeException: Array index is out of range.
Player.Update () (at Assets/Script/Player/Player.cs:60)
But the sound is playing!
The strage thing is when i trying to get the lenght of the array the debugger is telling me that it doensnt have such a variable but monoDevelop is telling me everything is fine.
Assets/Script/Player/Player.cs(62,46): error CS1061: Type `UnityEngine.AudioClip[]' does not contain a definition for `length' and no extension method `length' of type `UnityEngine.AudioClip[]' could be found (are you missing a using directive or an assembly reference?)
Thanks RaverTiny
Answer by RaverTiny · Dec 15, 2012 at 09:22 PM
Sorry, i fixed it my self. I Assigned the code 2 times to the Object but only one time the sounds. :D
Sorry
Please post an answer and accept it so people know exactly how you resolved the issue, or just close the question so it doesn't show up in "Unanswered". :)
I voted you up and gave you some $$anonymous$$arma points for showing people your resolution and accepting it :) Thank you for doing so.
Your answer
Follow this Question
Related Questions
Making sounds wait for each other to finish 2 Answers
Audio Script 1 Answer
Playing a sound clip from another object 1 Answer
Make the audio manager select from an array of sounds 1 Answer
Cannot read Array Length 2 Answers