Search Unity

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

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

  1. Laguna_Seca

    Laguna_Seca

    Joined:
    Mar 13, 2014
    Posts:
    114
    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.