Random AudioClip by their names,Random Clip
Hi everyone I am new on Unity and I try to make simge audio manager I was watching brackeys tutorial and I managed to make my game just trying to add music anyway
private void Awake()
{
foreach (Sound s in sounds)
{
s.source = gameObject.AddComponent<AudioSource>();
s.source.clip = s.clip;
s.source.volume = s.volume;
s.source.pitch = s.pitch;
s.source.playOnAwake = false;
}
FindObjectOfType<AudioManager>().Play("GameEntryMusic");
}
public void Play (string name)
{
Sound s = Array.Find(sounds, sound => sound.name == name);
s.source.Play();
}
I write a string name based find clip script , and It very usefull I can use it any script (FindObjectOfType().Play("GameEntryMusic");) like this however I have to make randomize it but I just couldnt figure that out. I have 4 clips name as succesful FindObjectOfType().Play("Success1"); Like this but I want them to play random any such as succes1,succes2,success3 like that. Any ideas ?
,
Your answer
Follow this Question
Related Questions
Random colors? 0 Answers
Randomly display an asset from Selection of assets 0 Answers
Random colors? 0 Answers
Random Scenes Without Repetition 1 Answer
Multinomial Distribution in Unity? 2 Answers