Search Unity

Resolved Sound not working

Discussion in 'Editor & General Support' started by Redafex, Jun 12, 2021.

  1. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    So i've gotten a problem recently where i can't play sounds, i checked EVERYTHING but i can't figure it out,
    if i press on stats in game window it shows me the i have audio level on -74.8 https://prnt.sc/155bjnm
    Any help?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,692
    Check the Game window doesn't have audio muted.

    Check Player -> Audio properties have a reasonable volume level.

    Check your audio source isn't positional and simply too far from the AudioListener.
     
    DonnaAG likes this.
  3. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    i did, i really did all of those, no luck tho
     
  4. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    Still need help
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,741
    How about your mixer is everything ok there?
     
  6. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    Yes i think my mixer is fine, never really messed around with the mixer
     
  7. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,692
    Make a blank scene, add a camera (which will have an audio listener), drag an audio clip on to the camera, press PLAY.

    Assuming you did the steps I listed last week above, then if you don't hear anything, then something else outside of Unity has gone wrong.

    OR your audio file is silent. Record another one. Download another one. This shouldn't take more than 2 minutes to suss out.
     
  9. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    it worked on the new scene, do i just remake the whole scene now?
     
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,692
    Start by dragging an audio clip onto the camera in your existing scene.

    This is just troubleshooting 101 : you have one thing in Timbuctu that doesn't work, you have one thing in Kansas that does work... start moving the two towards each other and as you do you will gain valuable insight and you will eventually either:

    1. bring Timbuctu to Kansas and find there IS something mythically wrong with Timbuctu

    2. isolate what it is about Timbuctu that doesn't work.

    I suspect it will be #2 if you are diligent.

    ALSO: it is a lot easier to work rapidly and destructively with this stuff when you are using source control, because you can trivially with a single click revert ALL experiments back to where you were when you started.

    Personally I use git because it is free and there are tons of tutorials out there to help you set it up.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    Here's how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up the right .gitignore file:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally setting Unity up (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity
     
  11. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    oh nice thanks, i'll move my project to git, and i will try and do the thing you asked me to and i will come back and see if it's fixed
     
  12. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    the reason on why it didn't work is so stupid, so basically right i had this piece of code "gunSound.pitch = Random.Range(-1, 1);"
    and for some reason it made all sounds in the game not work
    i really wanna know why
    didn't even produce an error, just sounds not working
     
  13. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    dammit i just figured out that i didn't specify that it's a float so it was always 0 or -1 which wouldn't produce sound at all
     
    Kurt-Dekker likes this.
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,692
    Yup, I've made that error. I think the most recent time was about a month ago on a fuel gauge... it would calculate percentage full based on dividing one integer by the other, so it would be 0 or 1, which I fed to the filled image percentage.

    That's why it's super useful to just rip everything out and start a fresh scene, get to something you know works, then start bisecting, trying stuff, even making notes of what you're trying to keep track of the circle of "I know this part works, something ELSE is rotten!"
     
  15. Redafex

    Redafex

    Joined:
    Oct 15, 2020
    Posts:
    12
    I see, thanks for the help
     
  16. VoidX_HUN

    VoidX_HUN

    Joined:
    Apr 20, 2015
    Posts:
    6
    Just in case someone else is searching for this problem, this is what happened to me: I use a Focusrite soundcard, which have extremely unstable drivers. It just crashed and had to be reconnected to fix all audio in Unity. What gave it away was YouTube also not working.