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

SERIOUS Audio Problems with UNITY 5

Discussion in 'Audio & Video' started by Barry100, Mar 8, 2015.

  1. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    hi all.. especially the devs.

    I have been having audio issues with audio sound not dropping off depending on distance.
    No matter what I do I cant get audio to drop off. I have ricochet sounds that are like this

    AudioSource.PlayClipAtPoint (GunSounds[1], startPos);


    this will play at full volume no matter where I am on the map. I though this was a problem with my code (although itwas working 100% until I started using UNITY5 the other day). So I changed the code to instatiate a game object at the vector3 position and play the audio using an AudioSource component attached to the instatiated object. This still played the sound at full volume (also btw I set the distances and everything so please dont say"did you set distance. I have been doing this for 3 days now with no results)

    Any ways, just messing round there I added a sound clip to a static object in the scene with a distance of 5 for the audio, volume half. So obviously if I am within 5 unity units from it I will hear it.. if I am 100 or so unitys away i will definitely not hear it. I hear it at 100% no matter where I am.

    This leads me to conclude that there is a serious issue with the unity sound in unity5 as I do not still have these problems when I set up a scene in unity 4.6 doing the same procedures.

    PLEASE FIX THIS UNITY!
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Make sure that the import settings on your audio still show it as a 3D sound after the update.
     
  3. Spellbound

    Spellbound

    Joined:
    Sep 9, 2011
    Posts:
    51
    The 3D option has been moved from clips to the actual audio source component. Makes much more sense than setting this on the clip being imported.

    You must make sure the Spatial Blend parameter on the audio source is set to 1.0 for full 3D based behaviour.
     
  4. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    How can this be done when using playclipatpoint ?
     
  5. KMonkey

    KMonkey

    Joined:
    Nov 12, 2012
    Posts:
    21
    not sure if this is the ideal workaround for now (also replied to the other thread) but I decided to add an Audiosource to each object I wanted 3D sound back easily and trigger the sound with:

    audio.PlayOneShot(sound1);

    etc...

    I couldn't find a nice way to have set defaults of the "playclipatpoint" to make them all have Spatial Blend set to 1
     
  6. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    118
    First, there is no serious issue. PlayClipAtPoint is a static method and does not use the settings of a particular AudioSource that is sitting on a particular GameObject. It instantiates a new one on the given position, and removes it after the sound has finished playing. With this in mind, what volume falloff curve are you expecting from it? Without a template, the only possible non-arbitrary option is to not have a falloff at all. If Unity 4 actually had a falloff, the behavior in Unity 5 would be a fix, not a bug.

    Consider one of these solutions:

    1: Declare a public AnimationCurve in your script, and create your falloff curve in the Inspector. Set the volume to yourCurve.Evaluate(Vector3.Distance(positionOfAudioListener, positionOfSoundEffect)), and you'll have a configurable falloff curve with potentially only two lines of code.

    2: Advanced, but more performance efficient: set up your own GameObject+AudioSource pool and implement a static class with your own PlayClipAtPoint method, and let that handle positioning and voice allocation, then you'll have full control over all the settings.
     
    Last edited: Mar 12, 2015
  7. OfficialDingbat

    OfficialDingbat

    Joined:
    Mar 12, 2015
    Posts:
    26
    I'm pretty sure this is incorrect but I could be mistaken. Yes the PlayClipAtPoint method doesn't use any settings from the AudioSource it is called from but the new AudioSource being created by this method always has a spatial blend of 0. Try it out yourself and see if I'm incorrect (for all I know I'm doing something wrong here.) The AudioSources created when using this method always appear to have a spatial blend of 0 which means the sounds coming from these audio sources will always sound 2D. Isn't this really counter-intuitive? Why would I want to use a method that plays a clip at a point if it will be played in 2D regardless of requiring a position to play from?

    Oh, and I was also having the same issue of bringing my project from Unity 4 to Unity 5 and having the PlayClipAtPoint method stop functioning properly.
     
  8. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    118
    I didn't consider the spatial blend part, I've still not upgraded to 5. You're right that it's obviously wrong to have a spatial blend of zero if the purpose of it is to play the sound in 3D space for panning reasons. But, say this was fixed. My original point would still hold up. Any volume rolloff other than none would be arbitrary, and relying on such a rolloff is bad practice.

    The feature to play a sound on an AudioSource with default/unknown settings sounds dodgy altogether. A much more usable solution would be a non-static method that uses the instance as a template for the new AudioSource's settings.
     
    Last edited: Mar 18, 2015
  9. Denis-Valjean

    Denis-Valjean

    Joined:
    Mar 25, 2015
    Posts:
    39
    Same problem here, no matter what settings... Unity 5
     
  10. ariyalion

    ariyalion

    Joined:
    Feb 15, 2014
    Posts:
    19
    you could try AudioSource.PlayClipAtPoint (GunSounds[1], startPos, 0.1f);
     
  11. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    589
    Do you use asset bundle?
     
  12. tcatik

    tcatik

    Joined:
    Jan 9, 2016
    Posts:
    1
    I had the same issue. Google didn't help me. So
    Maybe my case helps you.(Unity ver 5.3.1)

    Set "Spatial Blend" to 1
    Other parameters
    "Stereo Pan" = 1
    "Spread" = 0

    With these params MaxDistance should work. If you have any questions - ping me

     
    csch likes this.
  13. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Wouldn't setting stereo pan to 1 make everything play through just the right speaker? Wouldn't that be undesired?

     
  14. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,557
    I had no falloff, even with all he spatial blend set correctly. It was spotty so it would work one minute then not the next.

    I had upgraded my project from unity 4 to 5.

    I right clicked the audio files in my project hierarchy and chose "reimport" and "refresh" and so far they are working again.
     
  15. kubajs

    kubajs

    Joined:
    Apr 18, 2015
    Posts:
    58
    I've fixed the issue by setting "Volume Roloff Scale" in AudioManager (Edit / Project Settings / Audio) to 0.
    Before the value was 1 and I couldn't hear any sound at all while executing PlayClipAtPoint static method.
    PlayOneShot worked properly.
    HTH.
     
    deashh and moghes like this.
  16. EvyBenita

    EvyBenita

    Joined:
    Aug 8, 2015
    Posts:
    4
    Using Unity 5.3.5

    Two of my sounds works perfectly, while three don't. They've got the same import settings, and are called in the exact same ways but through different scripts. They work fine in the editor, but go all catchy and choppy during playmode. One of them seems to get stuck on the first one or two keys of the sound, then only finishes playing as I click to exit playmode. Any idea what I'm doing wrong?

    I'm fairly new to code, so it's most likely my fault. But I've been roaming the web for hours now looking for a solution, and it simply doesn't make sense that three of my audiosources don't work (to me at least).
     
  17. moghes

    moghes

    Joined:
    Oct 10, 2012
    Posts:
    14
    Any new results?
     
  18. moghes

    moghes

    Joined:
    Oct 10, 2012
    Posts:
    14
    Setting Volume Roloff Scale to 0 made some change, however some sounds play partially (a part from the audioclip), some don't, while some make a noise
     
  19. deashh

    deashh

    Joined:
    Jan 18, 2017
    Posts:
    1
    Thanks god... at least one person wrote a normal solution instead of just arguing uselessly.