Game Development Reference
In-Depth Information
and restart from the beginning. This method is also best for sounds that are moving in the space, or
that you need continuous pitch or volume change on. Additionally an audio.Pause() and audio.Stop()
command are available.
audio.PlayOneShot(<audioClip>);
This method is preferred for any layered sound ef ects you wish to create. Essentially what happens each
time this method is called is that an individual unseen Audio Source is created, plays the sound, and is
destroyed. PlayOneShot is great for when you want multiple copies, or instances, of a sound to exist. It
is also important to know that while you can change the pitch or volume of a sound before triggering, it
cannot be changed during playback.
audio.PlayClipAtPoint(<clip: AudioClip, position: Vector3>,initial volume: volume)
This method is somewhat similar to audio.PlayOneShot but will create an Audio Source and play the
AudioClip at a specii ed physical location in the game represented by the Vector3 value. This is actually
three numbers—for X,Y and Z locations). After playing it will clean itself up by destroying the Audio
Source afterwards.
Note the dif erences here— PlayOneShot requires an Audio Source to be present but PlayClipAtPoint
does not. This method also i xes a sound at the location specii ed (it can't move) and you cannot loop or
change pitch of the sound before or after. You can set the volume in this method, or leave it out if desired.
This method is great for something like a basic explosion sound to go along with a Prefab animation. The
animation plays at the same time as the sound ef ect does, and the Audio Source is destroyed when it
i nishes playing.
Example
any Game Object can be dragged over the Transform variable. It will use that object's location at that
point. For example, this will play the clip specii ed at the location at volume 0.9
var someLocation : Transform;
var mySound : AudioClip;
audio.PlayClipAtPoint(mySound, someLocation),0.9);
audio.PlayScheduled(<AudioSettings.dspTime : double>)
This is a new method that allows better much scheduling of an AudioClip, in combination with a
separate absolute sample time called AudioSettings . dspTime , expressed as a double (double precision
number—basically a very precise number).
This is much more accurate than the older method which is attached to frame rate. This rate can
l uctuate depending on a number of factors, which can easily throw the music timing of . This method is
independent of that timing and similar to the way that Wwise and FMOD Studio work. It works similar to
audio.Play in that it needs an Audio Source and a AudioClip specii ed.
 
Search WWH ::




Custom Search