Wassup guys im looking to randomize some “taunts” i have made for my character i just want him to randomly yell them out so to speak. I know or im pretty sure using an array is the best way
public AudioClip[6] rTaunts;
but can some tell me how to randomize the sounds in the array? it will be a total of 4-6 audio clips.
If you have an AudioSource called audio and an array of AudioClips called sounds,
audio.PlayOneShot(Random.Range(0, sounds.length);
ill give this a try thanks for a fast response:smile:
No problem.
You’re going to need to use sounds.length - 1, or you will get an error.
so :
audio.PlayOneShot(Random.Range(0, sounds.length - 1);
Yup. That will pick a random Clip to play from your array.