Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio The problem with sound. I do not understand how to configure the sound component.

Discussion in 'Audio & Video' started by AkhmedAbasov, Jan 11, 2019.

  1. AkhmedAbasov

    AkhmedAbasov

    Joined:
    Mar 13, 2014
    Posts:
    163
    Hello. I have a car to which I add a sound component.

    Code (CSharp):
    1.  
    2. var newAudio = go.AddComponent<AudioSource>();
    3.  
    4. newAudio.spatialBlend = 1;
    5.  
    6. newAudio.clip = clip;
    7.  
    8. newAudio.loop = loop;
    9.  
    10. newAudio.playOnAwake = playAwake;
    11.  
    12. newAudio.volume = vol;
    13.  
    14. newAudio.pitch = pitch;
    15.  
    16. newAudio.minDistance = minDistance;
    17.  
    18. newAudio.maxDistance = maxDistance;
    19.  
    This is what this component looks like:

    a1.png

    With these settings, the sound is not audible at all. The sound appears if you set the minimum to 20 and the maximum to 100.

    My problem is this: I have several locations on the same stage. They are far from each other. When I move to another location, I turn off the main camera and turn on the additional one. There is no sound listener on the secondary camera, but the sound appears and becomes very loud.

    How is this even possible? Why does the sound work if there is no listener on the camera? And how to properly adjust the sound for 3D space?

    I add a component from a script, since an object is created on the fly. I do not have the ability to adjust the curves.