Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Official Audio listener

Discussion in 'Open Projects' started by cirocontinisio, Jan 31, 2021.

?

Where should we put the AudioListener?

  1. On the camera

    7 vote(s)
    43.8%
  2. On the character

    8 vote(s)
    50.0%
  3. Somewhere else (explain in a post)

    1 vote(s)
    6.3%
  1. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    We currently have the
    AudioListener
    component on the camera, as is usual in many Unity games. This is totally fine for a 1st person game, but for our 3rd person perspective, where do you think the audio listener should be?

    If we choose to go with a solution that requires some code, we'll use this thread as a basecamp for that task.

    PS: I brought the question to Twitter too, plenty of interesting replies there! I suggest to check those replies before commenting - for the sake of not duplicating comments.
    https://twitter.com/CiroContns/status/1355940753202159621

    (and you can vote here or there, we're more interested in the reasoning behind)
     
  2. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Check the Twitter discussion linked above because the replies are on fire!
     
  3. nguyenfamily

    nguyenfamily

    Joined:
    Feb 3, 2021
    Posts:
    1
    Can the audio listener move around every time a sound is played?
     
  4. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
  5. randomscribe

    randomscribe

    Joined:
    Jun 14, 2021
    Posts:
    29
    I'd like to give this one a shot!
     
  6. randomscribe

    randomscribe

    Joined:
    Jun 14, 2021
    Posts:
    29
  7. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    While it might be more "performant" (but how much?) to not use a Unity message like LateUpdate, I think running it every frame is important, to give immediate feedback. Sound is super key to the experience.

    That's a thing I have been thinking too. One way would be, through the cutscene, to disable that AudioListener via an Activation track (or disable the whole playing character?) and activate another one (in the CameraSystem?).
    Or, switch the character Prefab to "cinematic mode", which in turn would disable the AudioListener object... need to give it some thought!

    I was also thinking maybe to fetch the transform we could use the "Anchor" system we have in the project, did you see it? That would be better than polling Camera.main (that also has a cost, but it could be cached) - and at the same time I don't trust Camera.main to always return the correct camera :D
     
    randomscribe likes this.
  8. randomscribe

    randomscribe

    Joined:
    Jun 14, 2021
    Posts:
    29
    Had not seen Anchor, will look into that next.
     
  9. randomscribe

    randomscribe

    Joined:
    Jun 14, 2021
    Posts:
    29
  10. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    I think that's good! Need to test it though. I will soon.
    Thanks!
     
  11. paciFIST_Studios

    paciFIST_Studios

    Joined:
    May 14, 2017
    Posts:
    14
  12. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
  13. paciFIST_Studios

    paciFIST_Studios

    Joined:
    May 14, 2017
    Posts:
    14
    thank you!