< Return to Video

Audio Sources & Listeners - Unity Official Tutorials

  • 0:00 - 0:03
    The Audio Listener component is the equivalent
  • 0:03 - 0:04
    of your ears in the game.
  • 0:05 - 0:08
    It receives, or listens, to audio sources
  • 0:08 - 0:09
    that are in the game world.
  • 0:09 - 0:12
    The control of the audio's behaviour is done on
  • 0:12 - 0:13
    the audio source component
  • 0:13 - 0:16
    and therefore the listener itself has no settings.
  • 0:17 - 0:20
    This is attached to a camera in your scene by default
  • 0:20 - 0:22
    but can be placed on any object.
  • 0:23 - 0:25
    Often this is attached to a character
  • 0:25 - 0:27
    and crucially there can be only one listener
  • 0:27 - 0:30
    per scene in order for it to function correctly.
  • 0:30 - 0:33
    You can test an audio listener from any position in the world
  • 0:33 - 0:35
    by moving the scene camera around
  • 0:35 - 0:38
    with the audio preview toggle enabled.
  • 0:54 - 0:56
    This gives you live testing of audio sources
  • 0:56 - 0:59
    in your environment without having to move
  • 0:59 - 1:01
    the real listener or play test the game.
  • 1:03 - 1:06
    Audio sources are components that playback audio.
  • 1:06 - 1:08
    Think of them as speakers in the game world.
  • 1:09 - 1:12
    In this example our turbine has an audio source attached
  • 1:12 - 1:15
    with the turbine audio clip that's been applied to it.
  • 1:15 - 1:17
    We can assign a clip by dragging and dropping,
  • 1:17 - 1:20
    or by using code to select a clip to play.
  • 1:20 - 1:23
    We can mute, bypass any filters,
  • 1:23 - 1:25
    choose whether to play this audio source on awake,
  • 1:25 - 1:27
    as in - when the game begins
  • 1:27 - 1:29
    and whether to loop the clip.
  • 1:29 - 1:32
    Priority varies between 0 and 255,
  • 1:32 - 1:34
    0 being the highest priority.
  • 1:35 - 1:38
    It's advisable to have music set as the highest priority
  • 1:38 - 1:40
    to avoid other clips from overriding
  • 1:40 - 1:42
    when many clips are being played at once.
  • 1:42 - 1:44
    Volume determines how loud the clip is played
  • 1:44 - 1:45
    based on it's original waveform.
  • 1:46 - 1:48
    Pitch controls the pitch of a clip.
  • 1:48 - 1:50
    If you're working with 3D sounds
  • 1:50 - 1:51
    the settings are more detailed.
  • 1:52 - 1:54
    Doppler level defines how much the Doppler Effect
  • 1:54 - 1:55
    will be used.
  • 1:55 - 1:58
    This is a perceived shift in frequency as the listener
  • 1:58 - 2:00
    or the ear in real terms
  • 2:00 - 2:02
    is moving past the sound source.
  • 2:02 - 2:04
    It will seem higher approaching it
  • 2:04 - 2:06
    and lower as it moves away.
  • 2:06 - 2:09
    Think of an emergency vehicle's siren as it passes you
  • 2:09 - 2:10
    for example.
  • 2:10 - 2:12
    Volume roll-off determines the type of roll-off
  • 2:12 - 2:14
    to be used by the sound
  • 2:14 - 2:16
    as the listener moves away from it.
  • 2:16 - 2:19
    This can be logarithmic, linear,
  • 2:19 - 2:23
    or customised manually using a curve
  • 2:23 - 2:25
    and adding keys as shown.
  • 2:30 - 2:32
    The minimum distance defines how close
  • 2:32 - 2:33
    to play the sound at full volume.
  • 2:33 - 2:35
    So if you are designing 3D sound
  • 2:35 - 2:38
    use this value to make the sound source louder.
  • 2:39 - 2:41
    This can be adjusted using the spherical Gizmo
  • 2:41 - 2:43
    in the scene view.
  • 2:49 - 2:51
    And it works in the conjunction with the
  • 2:51 - 2:53
    maximum distance setting below,
  • 2:53 - 2:56
    which by default is set to 500 metres
  • 2:56 - 2:58
    and is a distance after which
  • 2:58 - 3:00
    the sound rolls off.
  • 3:04 - 3:08
    Pan level defines how truly 3D the sound is.
  • 3:08 - 3:10
    This defaults to 1 for 3D sound
  • 3:10 - 3:12
    making it fully panned when the stereo listener
  • 3:12 - 3:13
    is moved past it.
  • 3:13 - 3:16
    Spread is the control of the angle of spread
  • 3:16 - 3:18
    from 3D stereo to multichannel sound.
  • 3:19 - 3:22
    Finally for 2D sound pan can be controlled
  • 3:22 - 3:23
    at the bottom of the component.
  • 3:24 - 3:25
    As a rule elements such as music
  • 3:25 - 3:27
    should be set to 2D sound,
  • 3:27 - 3:29
    whilst diegetic sound that should be
  • 3:29 - 3:31
    fading realistically should be set up
  • 3:31 - 3:33
    as 3D and positioned accordingly.
  • 3:34 - 3:36
    The 2D and 3D values of a sound
  • 3:36 - 3:39
    are controlled by an audio clip's import settings.
  • 3:40 - 3:42
    When selecting a clip in the project
  • 3:42 - 3:44
    you will be able to see the import settings
  • 3:44 - 3:45
    in the inspector.
  • 3:45 - 3:47
    You can choose the audio format to use,
  • 3:47 - 3:50
    whether it should be 3D or 2D sound,
  • 3:50 - 3:53
    whether you want to force your stereo sound to mono,
  • 3:53 - 3:57
    how to load it and what compression to use.
  • 3:57 - 4:00
    You can also preview sound at the bottom,
  • 4:01 - 4:03
    choose whether to loop whilst previewing
  • 4:05 - 4:07
    and set the inspector to auto-play
  • 4:07 - 4:09
    whilst browsing through clips.
Title:
Audio Sources & Listeners - Unity Official Tutorials
Description:

more » « less
Duration:
04:21

English subtitles

Revisions