Very simple code
public AudioClip soundToPlay;
public string tags;
void OnCollisionEnter (Collision collision) {
string[] splitTags = tags.Split(',');
for(int i = 0; i <= splitTags.Length-1; i++)
{
audio.PlayOneShot(soundToPlay);
}
The first collision, it plays, the second and thereafter, it does not. If I change it to audio.play() and put the audio clip in the audio source, it works fine. But I want to apply multiple audio clips to a game object this way so why is this not working? Is there a better way?