Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

How can I use one Audio Listener but to hear audio from other characters too ? I'm stuck

Discussion in 'Editor & General Support' started by Chocolade, Jan 28, 2019.

  1. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    937
    I have two cameras.

    1. FPSController ( Player) and his child FPSCamera. This is the player controller. When I enable the Audio Listener on the FPSCamera and moving the player around when walking through a door/s the doors open and I hear the doors audio when the door open/close.

    2. Main Camera. The main camera have attached to it a Cinemachine Brain. The Audio Listener on the main camera is disabled. I have a character that start walking using Animator and HumaoidWalk animation when running the game. The character walking through a door. But since the Audio Listener is disabled on the main camera I don't hear the door open/close when the character is walking through the door.

    And if I switch enable/disable the audio listeners on the cameras I will hear either this or either the other one when walking through a door.

    But in my case the character that walk with the animation is part of a cut scene and when I control the player I want also to hear the other character of the cut scene when he walk through a door.

    This is a screenshot of the player camera. The camera is enabled so when running the game I see this camera of the player and I control the player movements. Also the Audio Listener is enabled:



    Now a screenshot of the Main Camera. The Audio Listener here is disabled:



    The next screenshot show my Timeline and the 3 virtual cameras I'm using with the Main Camera in the Timeline. And it also show the character name medea_m_arrebola that the virtual cameras using the character to follow it and look at it:




    So for now I don't want to switch between the cameras !

    When the game is running the control is on the player but the cut scene is on action. The character medea_m_arrebola is already walking somewhere else in the scene. And I can hear the medea_m_arrebola steps I added a Audio Source to the character.

    But when the medea_m_arrebola is walking through a door the door is open but there is no audio of the door open/close.

    But when I move the player to a door there is audio of the door open/close.

    My problem is how to make that it will play the doors audio open/close when player or the character medea_m_arrebola walking through a door ?

    It seems like the Audio Listener of the player camera disable the doors audio for other characters that are not the player.
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    You can only have one AudioListener. Instead of trying to fix the AudioListener, you should be trying to fix the AudioSources.

    On an AudioSource, you can set the volume roll-off using the graph under "3D Sound Settings". The red line represents how loud your sound is at certain distances from your AudioListener. The right end-point of the red line respresents the volume at max distance. Using the red line, you want to make sure the volume at max distance is as loud as you'd like to hear it in-game, and you'll want to set the "max distance" value to be larger than the farthest distance your AudioSource can get from your AudioListener.

    One last tip: Make sure the red line in the 3D sound settings is flat or only has 1 curve. If it has 2 curves (or makes an S shape) you may find volumes get louder/quieter inappropriately based on distance.
     
    Chocolade likes this.
  3. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    937

    I don't think the problem is the audio source. If I enable the audio listener on the player camera and move the player through a door I hear the door open/close.

    Then if I disable the audio listener on the player and enable the audio listener on the main camera the character that walk through a door it will hear I will hear the door open/close.

    So the audio source is fine it's not that I can't hear it or that the volume is too low.
    It's just I can't make that when both the player and the character walk through a door it will hear I hear the two doors open/close.

    For testing I disabled both Audio Listeners on the player camera and the main camera and created a new empty gameobject and added to it a new audio listener. Now when running the game I hear the character walking through the door I hear the door open and close but when moving the player through a door I don't hear the door open/close.
     
  4. You aren't supposed to have more than one (active) Audio Listener in your scene, so you cannot hear both the player's and the cutscene's Audio Listener at the same time. If you want different spatial experience in mid-scene, you will need to position one listener before you play the cut scene.
    Also you can play with the spatial nature of your audio. For example you can make the cut scene audio not spatial so it can always be heard by any listener (2D).

    https://docs.unity3d.com/Manual/class-AudioListener.html
     
  5. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    937

    The problem is not to have two audio listeners. The problem is that I don't understand why when the audio listener only the audio listener on the player is enabled why then I hear all the scenes audio effects including when the player is walking through doors but when the character is walking through a door there is no sound of the door open/close ?

    What is so special or different between the player and the other character ? Why when the player is walking through any doors there is sound of the door open close but when the character walk through the door there is no sound of the door open close.

    It seems that the audio listener on the player camera is belong only the player and effect only the FPSController and not other characters.

    And another thing on the character that walk through the door I added audio source and I'm playing steps sound and I hear the steps with the player walking through doors and everything.

    The only thing that is not working is the doors. When the audio listener is enabled on the player camera FPSCamera the doors sound of open and close is not working for the character !!!! it's working for the player but not for the character.

    I don't want two audio listeners. I want to understand why when the audio listener on the player camera is enabled I don't hear the door open close on the character !!! but if the audio listener is enabled on the main camera and disabled on the player camera then I hear the character door audio open close but then I don't hear the doors open/close for the player.

    Why the audio listener on each one of them can't work for everything in the scene ?
    Why when enabling one of the audio listeners then other characters when walking through a door the door audio is not working at all ?
     
  6. Honestly, I don't understand your setup. You have an FPS character and the Cinemachine shots and you keep your FPS alive while you're shooting a cut scene?

    Because normally we don't duplicate cameras for Cinemachine. It uses one main camera (it happens to be your FPS one, whatever). It moves between the shots and when you're done with the cut scene it brings back to the player so the FPS part can continue.

    Unless you're working on picture in picture experience or split screen, you don't need two camera neither two Audio Listeners. Keep the one active and move between player and Cinemachine as it is designed.
    If you need your player to move in your cut scene (that is unreliable, player may not move into position to hear/see your cut scene), then you don't need Cinemachine, you need only timeline to animate the others throughout. So you will be able to hear whatever it is in distance to your player.

    If you want certain sounds to be heard all the time (like UI clings and heartbeat or whatever), use 2D clips, those aren't fade out by distance (see Audio Source settings).

    If it still doesn't work, you probably better off if you ask in the Cinemachine forum, maybe the Cinemachine disables something you're not aware of.