Play sounds based on their position in an array.

Hello, was wondering if it is possible to play a sound based off a name and a number.

So, this is what I’m trying to do:

soundName + 0.audio.Play();
soundName + 1.audio.Play();
soundName + 2.audio.Play();

I’d like to do this while looping through an array.

I am pretty sure you can do this in Flash, but I’m not sure it’s possible in Unity. Perhaps I have to create a list?

Any help would be appreciated!

This is possible, but it doesn’t work exactly the way you’re assuming it does.
Instead of “soundname + 0.audio.Play()”, it’s going to look more like “soundcollection[0].audio.Play();” <-this is not the exact syntax, just pseudocode.

What you’re trying to do is access array elements.
Check this: https://unity3d.com/learn/tutorials/modules/beginner/scripting/arrays