Play On Awake

Unity Audio Source

In by John FrenchPublished Updated

An Audio Source is a behaviour component in Unity that allows a game object to play an Audio Clip in the game scene, such as a sound effect or music.

By default audio sources are configured to play sounds in 2D, meaning that they can be placed anywhere in the scene. Adjusting the spatial slider to 3D allows the audio source to be positioned in the game world, meaning that the sound you hear will be relevant to the position of the Audio Listener, typically applied to the camera.

Typically, audio sources can be played using the public Play function, which will play the Audio Clip that’s been entered in the audio source’s audio clip field.

Alternatively, Play One Shot can be used to play any clip from the audio source once, meaning that multiple overlapping clips can be played from a single audio source.

Typically you’d use Play One Shot for sound effects, and the normal Play function for looping audio, such as ambience and music.