Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Problem with AudioManager (Brackeys tutorial based)

TigaLionessTigaLioness Member
edited May 23 in Programming

Hi, I hope I'm not gonna end up laughed at, but I'm quite dumb when it comes to programming and I'm still learning C# and Unity.

Once I did a tutorial by Brackeys "Introduction to Audio in Unity" on one of my projects in Unity 2018.4.10f and it worked flawlessly. I had different music for different levels, I had music theme and some effects on the player, enemies, picked up objects (it was a platformer in 2D).

Now I'm doing the exact same thing in 2019.3.0f5 and it's not working at all. After hitting play the Audio Source is created for a sound I add in AudioManager, it has the proper amount of volume and it's not playing. When I manually add an Audio Source on some other object (like Brackeys did in the beginning of the video) it works and the sound is played properly. Can it be the fault of the Unity version, or am I just doing something wrong?

I've searched a bit on that on Unity forum and it seems that it's still a problem (excluding people who accidentally checked "Mute audio" in Game window) and it remains unsolved. I tried making a build and the music isn't playing in build either. Many people say it's an issue with 2019 releases, but it's really freaking me out cause I need to finish my college project in Unity (in like 2-3 weeks) and I can't go back to 2018 releases, because some stuff I did wasn't really working in those. I'm downloading a little bit newer 2019 version but I fear that it won't fix the problem. I could do themes manually in Audio Sources on empty objects or something, but I also need some environment stuff like buttons, a sound of a starting PC etc, that are triggered after clicking on some objects in the scene.

Anybody having any ideas? I'd really use some help.

Comments

  • An interesting update - I downloaded an asset from here: https://assetstore.unity.com/packages/tools/audio/sound-manager-audio-sound-and-music-manager-for-unity-56087 and it doesn't play sounds either. Adding manually some Audio Sources to empty gameobjects on scene still works, but scripts or assets like these don't. I cannot upgrade my project to a newer version or an older one cause it just creates like billion of problems and errors. God help.

  • Would you mind providing additional screenshots or code snippets ? I think otherwise it might be quite difficult to provide help

  • Sure, here goes.

    That AudioManager empty is just based on Brackeys tutorial, so is the script "Sound". The only change I did was deleting the DontDeleteOnLoad and some additional audio settings like pitch variance, because I don't need those. I did the same damn thing in my project on 2018 release and it worked. I even on one point copy-pasted the old code from the 2018 release and it didn't work on 2019. I also gave you the screenshot of the game panel, I don't have the Mute Audio turned on and well, if the other way of giving the scene audio works then it's rather impossible anyway.

    The "Sound Trigger" gameobject that is currently inactive in the scene is just an empty with a Audio Source manually put there by me, and that one works when it's toggled active.


  • TigaLionessTigaLioness Member
    edited May 25

    OKAY I SOLVED IT.

    It was in front of my eyes the whole time but I spent so much time panicking I can't find the error and looking at the code without a break, that I just skipped it. At the second screenshot of the code above - the file called Sound.cs - there's a huuuge (sarcasm detected) dot before the 1f in the pitch line. I suppose it should be 1f to 3f, not .1f to 3f or at least, so that I would've seen the mistake - 0.1f to 3f. Unity somehow translates the value not to 1f as given in the code but the lowest possible in the pitch range array, which was nearly 0, and I've read threads before that pitch below 1f is not going to play sounds in the editor, player or the build.

    I hope my dumb ass which spent 9 hours searching for this little sneaky scrub dot is going to help anyone. Dunno if I can close this thread, but if any moderators are reading this then hey, you can close it for sure.

Sign In or Register to comment.