- Home /
how do i make audio clips for unity 3d?
i'm making thinking of making a single player mmofps gam.i wanna know how can i make audio clips? so i can import script them. i know about the sound recorder and on a side note, does audio clips from sound recorder work in unity?
A single-player massively multiplayer online first person shooter gam(e)? Someone already thought of thinking of making that - John Carmack in 1992.
Answer by devilkkw · Sep 04, 2011 at 09:54 AM
On unity some audio format works(wav,mp3,ogg). I don't understand what script are u speaking,for play audio just use correct function.See thath on the default documentation.
Answer by aldonaletto · Sep 04, 2011 at 11:35 AM
PC Sound Recorder saves the sounds by default in WAV, and Unity can read most audio formats, including mp3, wav, aif (Mac standard). But the Windows Sound Recorder isn't a good software - use GoldWave, from www.goldwave.com; it's easy to use, has a fully functional demo version and several resources to record, edit, apply effects and save. Once you have the sound ready, import it to Unity via menu Assets/Import New Asset....
In Unity, you can place the sounds in objects adding an AudioSource and setting its clip variable to the sound. If you want the object to emit the sound by script, use audio.Play(); if you want the same object to play different sounds in certain cases, declare one AudioClip variable for each sound, and set audio.clip with the desired one prior to Play; another way is to declare the variables and play the sound you want using audio.PlayOneShot(sound, volume). There go some usage examples:
var sound1: AudioClip; // set the sounds in these variables var sound2: AudioClip; var sound3: AudioClip;
function PlaySound1(){ audio.clip = sound1; // define which sound to play, if not already defined audio.Play(); }
function PlaySoundN(n: int){ switch (n){ // play one o case 1: audio.PlayOneShot(sound1, 0.5); break; // play at half volume case 2: audio.PlayOneShot(sound2, 0.7); break; case 3: audio.PlayOneShot(sound3); break; // play at max volume (default) } }
Aldo, if you want to use pre tag, be sure to add extra blank line, otherwise UA/QATO screws it up (fixed)