OpenAL + Ogg/Vorbis abstraction
To play a sound you need an AudioSource, every object in your game making noise should be mapped to a different AudioSource to have correct mixing.
AudioSource heroAudioSource = new AudioSource(); AudioSource zombieAudioSource = new AudioSource(); AudioSource backgroundMusic = new AudioSource();
You need sound files in the popular Ogg/Vorbis format. Tiny sounds (like effects, noises, ...) are mapped to AudioClip, while long sounds (like background music) have to be streamed constantly from the disk.
AudioClip jumpSound = new AudioClip("Assets/jump.ogg"); AudioClip attackSound = new AudioClip("Assets/shot.ogg");
To play clips just issue the Play() command:
while if you need to play longer sounds from disk (instead of folly loading them in the memory like with AudioClip):