Ok I’m trying to get a sound to play from an array. I want my sound to play using an animation even called from a C# script but I keep getting an error message saying:
IndexOutOfRangeException: Array index is out of range.
Here is what I have as my script set up:
//Random Clips
public AudioClip[] VoiceClips;
public void KITTvoice01()
{
AudioSource.PlayClipAtPoint(VoiceClips[Random.Range (0, VoiceClips.Length)], Camera.main.transform.position);
}
How many clips have you assigned to the VoiceClips array in the inspector?
– tanoshimii currently have 4 in the array but want to add more eventually
– KnightRiderGuy