Introduction to AUDIO in Unity

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 1,7 тис.

  • @mr.mysteriousyt6118
    @mr.mysteriousyt6118 7 років тому +3346

    don't stop teaching us.

  • @TheGrimmGamer
    @TheGrimmGamer 3 роки тому +444

    That feeling when you follow the tutorial, set everything up, tear your hair out for 3 hours wondering why the sound won't play... and then change the pitch from 0 to 1.

    • @stripeysoup
      @stripeysoup 3 роки тому +20

      OMG THANK YOU.

    • @maxplayerone9565
      @maxplayerone9565 3 роки тому +9

      The legend that saved me weeks of debuging- Grimm himself. Thanks dude!

    • @goodgamershow6505
      @goodgamershow6505 3 роки тому

      @@maxplayerone9565 do we need to change [Range(0.1f, 3f)] of pitch variable to 1f,3f or what?

    • @goodusername4901
      @goodusername4901 3 роки тому +2

      @@goodgamershow6505 i think you need to look at the Audio_Manager game object's script component

    • @persimmon93
      @persimmon93 3 роки тому +1

      Your comment saved my hair. My hair thanks you.

  • @NightcoreMotion
    @NightcoreMotion 7 років тому +571

    If anyone is curious on how to stop playing a looping sound (maybe you want to switch bg music when you enter a new area) just use s.source.Stop (); You can just add a method to the Audio Manager like this
    public void StopPlaying (string sound)
    {
    Sound s = Array.Find(sounds, item => item.name == sound);
    if (s == null)
    {
    Debug.LogWarning("Sound: " + name + " not found!");
    return;
    }
    s.source.volume = s.volume * (1f + UnityEngine.Random.Range(-s.volumeVariance / 2f, s.volumeVariance / 2f));
    s.source.pitch = s.pitch * (1f + UnityEngine.Random.Range(-s.pitchVariance / 2f, s.pitchVariance / 2f));
    s.source.Stop ();
    }
    just call it like this (AudioManagerReferenceGoeshere).StopPlaying("sound string name");

    • @arnedebeer
      @arnedebeer 7 років тому +6

      Hey Nightcore Motion, I was just like you using s.source.Stop(), but it keeps giving me a NullReferenceException that the source equals to null, any idea on how to fix that?

    • @SasukeUchiha723
      @SasukeUchiha723 6 років тому +17

      You should actually write it at the place where you want to stop bgm 1 and play bgm 2.
      if (blah blah){
      FindObjectOfType ().StopPlaying ("GameplayMusic");
      FindObjectOfType().Play("MenuMusic");
      }

    • @ItsBenniiBoii
      @ItsBenniiBoii 5 років тому +4

      You sir, are a lifesaver!

    • @praveenkrishna8885
      @praveenkrishna8885 5 років тому +5

      I want to fade in the audio in start how to do that.

    • @kishiosakai2649
      @kishiosakai2649 5 років тому +1

      Wow thank you, I was trying for hours :D

  • @imconfused6955
    @imconfused6955 7 років тому +802

    Is the audio just you making noises

    • @diegocrusius
      @diegocrusius 7 років тому +11

      preprocessing with what, please?

    • @diegocrusius
      @diegocrusius 7 років тому +6

      hmm I think I remember using audacity to cut and convert some audio files Didnt know you could go much further. Thanks.

    • @diegocrusius
      @diegocrusius 7 років тому +5

      thank you for your kindess

    • @Brackeys
      @Brackeys  7 років тому +634

      NO!
      ...
      Okay yeah :)

    • @chickentim8505
      @chickentim8505 6 років тому +7

      xD

  • @Joohyunsang
    @Joohyunsang 3 роки тому +6

    This video is 4 years old, but it still legit!! I was struggling to find a way to manage game audio files until watching this. Many thanks to Brackeys!!

  • @NewbNinjas
    @NewbNinjas 2 роки тому +32

    OK Guys, for some of you that will likely be getting a Null:Exception Error you might need to check that you aren't trying to Play() the sound in an AWAKE function on another object. I had this problem and for about a month I've been pushing it to the side and figured I'd get around to fixing it later when it became a little more important.
    SO the problem I had was I used the same setup as in the tutorial, with another class I called Jukebox. This was to handle the current soundtrack playing and to allow players to cycle between other soundtracks in the game, like a Jukebox :D
    Long story short, I was calling the following lines of code:
    audioManager = FindObjectOfType();
    audioManager.Play("music_metal_1");
    within the Jukebox.Awake() function. This is a NO NO. The SOURCES aren't populated until later which means when I was trying to invoke them they hadn't actually been setup ;)
    To get around this I simply called the same code in the Jukebox.Start() function which worked absolutely fine.
    I hope this helps one other poor soul out there then I know my suffering was not in vain. This post isn't actively monitored so my query went almost 2 months without a single response. I hope this helps someone.
    Never Give Up

    • @Noobyoulus
      @Noobyoulus 2 роки тому +1

      Thank you!!!

    • @TheBrunoRM
      @TheBrunoRM 2 роки тому

      @@Noobyoulus So basically, only use Awake() to initialize the class that method is in, and use Start() to get references from other classes, making sure the other classes have already been initialized by the Awake method.

  • @In-N-Out333
    @In-N-Out333 6 років тому +121

    Move these two lines of code:
    s.source.volume = s.volume;
    s.source.pitch = s.pitch;
    from Awake to the Play function. That way you can adjust those values in real time while the game is running.

    • @skiesquiggles7319
      @skiesquiggles7319 5 років тому +2

      Brorger

    • @Diego0wnz
      @Diego0wnz 5 років тому

      How to control them all at once?

    • @DavidBixler
      @DavidBixler 4 роки тому

      This doesn't work for me unfortunately.

    • @DavidBixler
      @DavidBixler 4 роки тому

      So this works, except for the music. It doesn't seem to allow change at runtime for the currently playing sound.

    • @sumogre1822
      @sumogre1822 4 роки тому

      @@DavidBixler How'd you do it?

  • @aidan_byrne
    @aidan_byrne 4 роки тому +17

    This is by far one of the most straightforward and easy to follow tutorials I have watched in quite a while!

  • @MT-nd5ut
    @MT-nd5ut 2 роки тому +31

    For anyone that's struggling with ArgumentNullExceptions when you switch scenes, it's because you're referencing the wrong AudioManager. For example, if you switch scenes, the AudioManager in the scene gets destroyed by the singleton code, but you call Find() on it instead of the singleton instance of the AudioManager from a previous scene. In other words, you shouldn't use Find() but rather AudioManager.instance when referencing the AudioManager.
    In fact, if your game always starts at the main menu of your game then you only need one AudioManager instance in the main menu hierarchy, but I'd still recommend keeping AudioManagers in every scene.

  • @LILMAN_official
    @LILMAN_official 4 роки тому +3

    If you are new to coding and you arnt able to take classes I would suggest following along and paying attention with alot of beginner coding videos, it really does help, this channel its self is probably one of the best places to start.

  • @localSunMan
    @localSunMan 7 років тому +9

    Thank you a lot for this tutorial. I spent multiple days figuring out a way to keep the music nice and clean throughout scenes and after finding a somewhat working method, your tutorial is like a gift from the heavens (the internet heavens). Love your tutorials, love your good attitude, can't wait for the next one!

  • @tonihenriksson2399
    @tonihenriksson2399 4 роки тому +6

    I have watched your videos for ages , learning a shit ton from them.
    I just realized i never thanked you for the videos.
    So.. THANK YOU! You are really motivating me through my struggles :D

  • @shehzaanansari8204
    @shehzaanansari8204 7 років тому +144

    Great video as always!

  • @rigzmoviediaries654
    @rigzmoviediaries654 5 років тому +46

    Brackeys, without you I would be lost and stuck paying for a course. Thank you.

    • @fv4202x
      @fv4202x 4 роки тому

      how are you now?

    • @rigzmoviediaries654
      @rigzmoviediaries654 4 роки тому +5

      @@fv4202x My interest in game development has definitely decreased, but my skills and craft have definitely increased. I'm still planning on releasing games one day.

    • @artyWeeb
      @artyWeeb 4 роки тому

      @@rigzmoviediaries654 good luck

    • @cheesedabber
      @cheesedabber 3 роки тому

      @@rigzmoviediaries654 and how is that going for you now?

  • @diegocrusius
    @diegocrusius 7 років тому +79

    if I could marry a youtube channel it would probably be this. One of the best Brackeys videos I saw so far.

  • @Aessa7
    @Aessa7 6 років тому +1

    Dude I love your direct style, you don't waste ANY time, and you trust the viewer to understand. Thank you so much.

  • @nikitaprodanov5219
    @nikitaprodanov5219 5 років тому +7

    It`s amazing that there are still people like you who keep helping others without wanting something for exchange. Love your vids. I wish you luck and don`t stop making this awesome tutorials.

  • @gamerheroine
    @gamerheroine 3 роки тому +2

    I've rewatched this video so many times! Its such a good resource. Everytime I get to doing audio in a game I pull this up again for a refresher.

  • @johncisors4832
    @johncisors4832 7 років тому +78

    Love your sound effects :D

    • @Brackeys
      @Brackeys  7 років тому +23

      Haha, thanks! :)

    • @dmitrij34
      @dmitrij34 7 років тому +2

      +Brackeys Why Array.Find? Why not a dictionary with try get value instead?

    • @sfaezamin
      @sfaezamin 5 років тому

      Its just his voice

    • @place_holder2160
      @place_holder2160 3 роки тому +2

      @@sfaezamin no shit sherlock

  • @houssam3009
    @houssam3009 3 роки тому +1

    The more I watch the more I miss you man thanks for all the awesome tutorials.

  • @marxiplier4322
    @marxiplier4322 4 роки тому +5

    Finally, I've been looking at a bunch of overly complicated sound managers that I can't seem to get to work, and then you come along and make it so much simpler and actually work.

  • @samuelleigh2270
    @samuelleigh2270 10 місяців тому +1

    Still using this 6 years later! Thanks!

    • @IdleGamer208
      @IdleGamer208 10 місяців тому

      me too

    • @michaelanonymous3104
      @michaelanonymous3104 4 місяці тому

      me too but.... "MissingReferenceException: The object of type 'AudioSource' has been destroyed but you are still trying to access it" and no I didn't alter the code

  • @Junglej0hn
    @Junglej0hn 6 років тому +4

    Very nice solution, if I may add one thing then instead of finding the gameobject reference every time you want to play a sound, you could write a static function in the audiomanager:
    public static void PlaySoundStatic(string name)
    {
    if (instance == null)
    {
    Debug.Log("No audio manager ");
    return;
    }
    instance.PlaySound(name);
    }
    Then we use the current active audiomanager to play the sound. Then you would write "AudioManager.PlaySoundStatic(string mySoundName);" to play a sound from anywhere.

  • @rastarish3201
    @rastarish3201 7 років тому +2

    Quite possibly, one of the most useful Unity tutorials I have ever come across! Thanks Brackeys!

  • @BestJohnEver
    @BestJohnEver 7 років тому +5

    You rock man! Great programer, very organized and well explained! Thank you and never stop doing this videos!

  • @oxenfree6192
    @oxenfree6192 5 років тому +1

    You're an amazing instructor. Please never stop. Your videos are so clean and direct, and you cover information so well.

  • @jasonallen2602
    @jasonallen2602 2 роки тому +9

    MAKE SURE you give the pitch a value that is NOT zero. Spent hours trying to figure out why my audio wasn't playing and realized it was because I never touched the pitch value and because it defaults to zero you get no sound.

  • @umadkuzubad
    @umadkuzubad 4 роки тому

    You are amazing! Years later and I'm still using your videos with great success. Thanks Brackeys.

  • @turkym7md5
    @turkym7md5 6 років тому +24

    1:36 i could say that you stick your mouth on the microphone and say "phooooophooooooophoooooo" xD

  • @hamez6970
    @hamez6970 2 роки тому +2

    i love the way these guys made sounds, with their mouth

  • @RealRushinRussian
    @RealRushinRussian 2 роки тому +5

    I don't understand. So you design a custom Sound class that has most of the core data that a stock AudioSource already has. You then make a messy, obscure Inspector interface to interact with it - I mean, try to remove or add a sound from/to the middle of the list and see how that works... Only to just copy all the custom Sound data fields into the hidden AudioSources on Awake.
    What is the point of all of this other than to make everything obscure and ridiculously difficult to maintain once you have more than 2-3 sounds?
    Make an empty object that contains an AudioSource. Make a prefab out of it. Add a prefab instance for every sound you want to have; name your objects accordingly in the hierarchy. Make them all children of an AudioManager object. Take the whole object (with all children) and save them as a prefab as well. Just add this prefab to every scene. To add a new sound, simply go to prefab-editing mode and do what you must. No restrictions on deleting, adding, or changing the order of your sounds. No need to duplicate the data between a custom class and an actual AudioSource. You could even have separate sound lists per scene which is also super easy to set up.
    There are probably far better approaches to this as well, but this one is a straight up mess. Don't make lists of custom classes that you fully set up from the Inspector. Either load the data from a file (json, csv etc) or set it up with objects but don't go for the Inspector approach. Just the fact that you can't modify the order of your sounds alone should ring alarm bells. So should the data-duplicating. It's not viable for anything beyond a simple test scene. Like, I get that it's supposed to be a lesson for beginners but it's still a horrible approach.

    • @cjplanes
      @cjplanes 2 роки тому +1

      Goddamn you are a genius

    • @tegxi
      @tegxi 2 роки тому +2

      I like your method, it seems far less janky. Though given that this tutorial is 5 years old your hostility seems excessive.

  • @Random_Coffee_Cup
    @Random_Coffee_Cup 4 роки тому +1

    I noticed that the car did not destroyed when you go forward in one way haha and u said make thing like when player go in one way for some time respawn one ticket on his way! Don't stop man your videos is helping a lot

  • @Retr-eo5uz
    @Retr-eo5uz 7 років тому +238

    You're the best !

  • @SuperDutchrutter
    @SuperDutchrutter 3 роки тому +1

    So useful. Going to miss the new uploads but hope your new adventures suit you well.

  • @deaf_conformist
    @deaf_conformist 4 роки тому +7

    Sorry, when I heard the first sound of the car, I had to stop the video, I couldn't stop laughing ... I was like "ok, it is going to show us a professional car sound, recorded with a good mic ...." and suddenly ... "fffrrruuuuuummmmMMM"

  • @tahahusain7328
    @tahahusain7328 4 роки тому +1

    Please Don't Stop Teaching Us Unity, We All Love You And Your Tutorial's. Thanks For Teaching Us Unity For Free

  • @IronDizaster
    @IronDizaster 6 років тому +278

    *you know, coding is easier than you think.*

    • @synthjc5105
      @synthjc5105 5 років тому +35

      You Know You ShOuLd TaKe ThIs OnlNe UniTy On UnEdEmy

    • @shk_
      @shk_ 5 років тому +9

      @liberP lovPrimeNumbers YoU KnOw YoU dO

    • @Ab-gj1jw
      @Ab-gj1jw 4 роки тому +19

      You know, coding is easier than you think when you just copy.

    • @apainush9540
      @apainush9540 4 роки тому

      change my mind

    • @TGR-ll8mc
      @TGR-ll8mc 4 роки тому

      @@synthjc5105 fucking hate that ad

  • @pedrosalaspinero7220
    @pedrosalaspinero7220 4 роки тому +1

    YOU RESCUED ME FOR MY FIRST GAME JAM LOVE YOU FOREVER

  • @SpeedySpee
    @SpeedySpee 6 років тому +10

    If you are still looking to download and the link doesn't work!
    Use this link.
    old.brackeys.com/wp-content/FilesForDownload/AudioManager.zip

  • @ignatiusreilly8280
    @ignatiusreilly8280 4 роки тому

    The visuals and lighting and smoke are awesome looking in that little game.

  • @shreddernation1096
    @shreddernation1096 5 років тому +9

    My dude made a game about king Kai’s planet 😂😂 great vid man!

  • @GerGauss
    @GerGauss 3 роки тому

    This video has just saved me. I have been struggling for a week with this issue, I should have known better and have come here earlier

  • @TigaLionessArt
    @TigaLionessArt 4 роки тому +13

    Okay, so I know this video is like a thousand years old and probably nobody will help me, but I did this tutorial (with success) on one of my projects in Unity 2018.4.10f and it worked. 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?

    • @sulkingcrow7426
      @sulkingcrow7426 4 роки тому +4

      I'm not sure if this is still relevant but I had the same problem and had to set the pitch to 1

    • @TigaLionessArt
      @TigaLionessArt 4 роки тому +3

      @@sulkingcrow7426 Yeah I figured it out a day later. The script had mininal value of pitch set to 0.1, but it was written .1 so I had missed the fact it's not 1. And Unity treats any value of pitch under 1 as if it was set to 0. But anyway, maybe someone will have a similar problem and get to learn quicker what was wrong, than I did ;)

    • @SillyCraftersOcCheng2000
      @SillyCraftersOcCheng2000 4 роки тому +2

      @@TigaLionessArt Thank god i see the comments here so can finish my game devoloping project for uni

    • @jhgfghjfuzrtfchchghgf
      @jhgfghjfuzrtfchchghgf 4 роки тому +1

      @@sulkingcrow7426 thanks for posting this! I was trying to get this to work for over an hour. this tutorial is broken :(

    • @sulkingcrow7426
      @sulkingcrow7426 4 роки тому

      @@jhgfghjfuzrtfchchghgf no problem! And it was a great tutorial, just a small (but important) part got looked over

  • @waterandtreefilms
    @waterandtreefilms 7 років тому

    MY GOD!!!! Your tutorials have come a long long way! i think you have cracked the key to making the best tutorials. Fast but explanatory. New Fav GameDev Channel

  • @codersexpo1580
    @codersexpo1580 4 роки тому +4

    GREAT VIDEO! If I may add ...
    Since the audio "Name" is created when you add it to the Audio Manager, it might be best to add that name to the Audio Manager Enum. Like so...
    public enum AudioSounds
    {
    ShipEngineThruster = 0
    ,
    SomeOtherSoundName = 1,
    YetAnotherSountName = 2
    }
    ...and then from any component using the Sound Manager that sound can be called by name like...
    audioManager.Play(AudioManager.AudioSounds.ShipEngineThruster);
    ...and in the Audio Manager's method to Play, we have...
    public void Play(AudioSounds name)
    {
    var s = FindAudioClip(name);
    if (s != null)
    {
    if (!s.source.isPlaying)
    {
    s.source.Play();
    }
    }
    }
    private Sound FindAudioClip(AudioSounds name)
    {
    return Array.Find(sounds, sound => sound.name == Enum.GetName(typeof(AudioSounds), name));
    }
    I hope you like this addition ;-) Love the work you do!!

    • @codersexpo1580
      @codersexpo1580 4 роки тому

      I also wanted to just add, if folks are not familiar with what you were doing @13:10, this is called a singleton pattern (which I believe he mentions) and I would highly suggest anyone not familiar with this pattern to research it. In fact Jason W @ ua-cam.com/video/hQE8lQk9ikE/v-deo.html does a nice job of discussing this pattern as well as a few others often used in development. Thanks again for an awesome video.

  • @sumitgohil2636
    @sumitgohil2636 7 років тому

    You're one of the best online tutor I've came across. There's a lot to learn from you. Please don't stop teaching and keep doing this wonderful deed. God Bless You.

  • @nonnodacciaio704
    @nonnodacciaio704 7 років тому +16

    What if I want to stop the theme music, for example when Player dies?

    • @Yar3920
      @Yar3920 6 років тому +1

      Nonno d' acciaio then destroy the audio manager

    • @JasonEkonomakos
      @JasonEkonomakos 6 років тому +9

      No, don't destroy the audio manager, why would he do that? Simply call the music using the audio manager and either pause it or stop it

    • @dadmanful
      @dadmanful 6 років тому +1

      lol

    • @zoewalker2064
      @zoewalker2064 6 років тому +2

      @@JasonEkonomakos how tho???

    • @JasonEkonomakos
      @JasonEkonomakos 6 років тому +5

      @@zoewalker2064 I have a different set up for my audio manager, but, looking back at this video, notice how he sets up the Play function. In the audio manager, Play takes a string input and finds the audio file with that name. The quickest solution to your problem is simply copy and paste the Play function, rename it Pause, and instead of writing "s.source.Play()" write "s.source.Pause()". Then when you want to pause a sound, just call the audio managers pause function and pass the audio files name as the input

  • @jroenning
    @jroenning 4 роки тому +2

    all your videos are just so easy to use and straight to the point
    thank you so much

  • @gulraiz19
    @gulraiz19 2 роки тому +3

    Move these two lines of code:
    s.source.volume = s.volume;
    s.source.pitch = s.pitch;
    in Update() function in the AudioManager Script.
    Like this:
    private void Update()
    {
    foreach (Sound s in sounds)
    {
    s.source.volume = s.volume;
    s.source.pitch = s.pitch;
    }
    }
    That way you can adjust those values in real time while the game is running.

  • @VirtualTurtleGames
    @VirtualTurtleGames 7 років тому +2

    It's amazing how by watching these videos I learn about how little I know of coding. I love that feeling because it means there is so much more to learn! Thanks for the videos ":D

  • @lunarfoxgames
    @lunarfoxgames 3 роки тому +3

    Anybody watching this now who doesn't want to mess around with the pitch each time, just change this in Sound.cs:
    public float pitch = 1f;
    This will default the pitch in the inspector to 1, that way you don't need to manually do it each time. You can also make the volume at a default like this.

    • @Ajaxlancer
      @Ajaxlancer 3 роки тому

      Would you know how this would manage a PlayOneShot function? For instance, I have a gun that fires automatically and I don't want the sound to cut itself off without playing the full firearm sound effect.

  • @dartutorials7859
    @dartutorials7859 4 роки тому +2

    if you cant hear sound in unity you might have to go into project settings - audio and uncheck "mute audio" or set master volume to 1 or in your game view at the top bar uncheck mute audio

  • @ARTHUR14523
    @ARTHUR14523 4 роки тому +5

    Now how do we play these sounds from the Master mix that we made in your other video so we can decrease volume from the slider?

  • @ravestechworld6445
    @ravestechworld6445 4 роки тому +1

    Thank you soooo much bracks you have no idea how many people have you helped!

  • @taragitaratayo2304
    @taragitaratayo2304 6 років тому +11

    Hey man! quick question, I've succesfully added the Audio manager , problem occurs when i try to combine the adding settings and slider control / mixer in my game . since yours creates a a new component .. how would i go about adding the mixer source on the component via script. Many thanks!

    • @Averysh
      @Averysh 5 років тому +3

      Did anyone figure this out yet?

    • @kingdavegamess
      @kingdavegamess 5 років тому +17

      @@Averysh if you did the "Introduction to AUDIO in Unity" you need to add another component to the Audio Manager and Sound Class .
      in the Audio Manager :
      s.source.outputAudioMixerGroup = s.group;
      in the Sound :
      public AudioMixerGroup group;
      and then add in the group : "Master(MainMixer)" I did so
      and it worked ,hope it helps .

    • @serbaneduard5045
      @serbaneduard5045 4 роки тому +1

      @@kingdavegamess thx. You help me a lot.

    • @kingdavegamess
      @kingdavegamess 4 роки тому

      @@serbaneduard5045
      no problem

    • @isaialusuardi
      @isaialusuardi 4 роки тому +1

      @@kingdavegamess Thx it works!!!!

  • @nextcent
    @nextcent 4 роки тому +2

    Fantastic tutorial! So useful! I had a problem in the Singleton code, because we had a "return" there, the sounds array was not being processed when the game went from level 1 to level 2 and I was getting a null reference error. I removed the "return" and everything worked fine. Thank you for sharing this.

  • @BlaZeLiink
    @BlaZeLiink 7 років тому +9

    Could you make a video about handling animation?
    For example: Weaponswitching in a fps
    You got an animation for putting down the current weapon. You also got an animation to pull out the second weapon.
    I implemented it one way, but it's not clean. I implemented a class, which starts a couroutine, which sets a bool in the animator of my current weapon, waits a second so it's finished, and then plays the next animation.
    I saw a lot of "tutorials" which try to create an animator-script. I don't think this apporach is good either.

    • @tudordumitrescu8707
      @tudordumitrescu8707 7 років тому +1

      DerLink he literally did a vid a week ago on this

    • @BlaZeLiink
      @BlaZeLiink 7 років тому

      if you refer to his weapon switching tutorial, that's not what I meant (not quite)
      I meant a tutorial about how to handle animation, I. e. import from a blend file, using mecanim.
      Like, wait for animations to finish using couroutines, implement clean animation transitions, the best way to implement animator controllers with blend trees, etc...

    • @jrgen7527
      @jrgen7527 6 років тому

      I think maybe you should look into state machines @DerLink

  • @stevanivanovic9579
    @stevanivanovic9579 2 роки тому +1

    Love the car voiceover work

  • @zacharyseebeck2409
    @zacharyseebeck2409 7 років тому +10

    I can't get any sound to come through. Even when directly copying and using your script. I can run the code with no error, but no sound either.

    • @ferguslees7994
      @ferguslees7994 7 років тому

      Got the same issue here, appears in the audio manager but does not play...

    • @jeroeno_boy149
      @jeroeno_boy149 6 років тому

      same

    • @Shavinderyt
      @Shavinderyt 6 років тому +10

      late reply, but for other people, make sure your pitch is above 0. 1 is the normal sound without any pitch changes. and volume needs to be up too! this worked for me

    • @DarthZmex
      @DarthZmex 6 років тому

      Was working until I set it as a prefab, then even trying again from the begining it didn't work, the pitch is well set also

    • @jeroeno_boy149
      @jeroeno_boy149 6 років тому

      try design your own, worked for me

  • @ioverexcitedninja4281
    @ioverexcitedninja4281 Рік тому

    Your tutorials are by far the best i could find out there 👍

  • @Dezmondo777
    @Dezmondo777 7 років тому +27

    The link to Audio Manager is not available anymore :((

    • @jeroeno_boy149
      @jeroeno_boy149 6 років тому +34

      old.brackeys.com/wp-content/FilesForDownload/AudioManager.zip

    • @seifmustafa2004
      @seifmustafa2004 6 років тому +4

      thanks mate :)

    • @MINTYBIBI
      @MINTYBIBI 5 років тому +3

      @@jeroeno_boy149 thx u so much

    • @DexterCrappell
      @DexterCrappell 9 місяців тому

      ik, and it hurts cuz i need it to find my issues. I CANT FIND ANOTHER VIDEO THAT SHOWS MY FKN PROBLEM!@!!!@@!@@!@!@!!!!@@!

  • @skyacaniadev2229
    @skyacaniadev2229 6 років тому +1

    Those lovely mouth-crafted audio clips...

  • @Kaikaku
    @Kaikaku 7 років тому +14

    Good timing, so far I have no audio in my program. This will now change :)

  • @fateshow5303
    @fateshow5303 4 роки тому

    This is the only video that I've found that has successfully worked for me. Thank you!

  • @jeevat8164
    @jeevat8164 6 років тому +8

    0:36 "Let's add some silence"

  • @oxygeninvestor1097
    @oxygeninvestor1097 4 роки тому +1

    As always your tutorials are remarkably helpful.

  • @CeretPenyok
    @CeretPenyok 7 років тому +22

    I can't hear the sounds when the object instantiated.

    • @benbuehler4972
      @benbuehler4972 5 років тому +14

      pitch needs to be at least .1f for sound to be made.

    • @maiskorrel
      @maiskorrel 5 років тому

      @@benbuehler4972 Thanks!

    • @TheNamelessTO
      @TheNamelessTO 4 роки тому

      @@benbuehler4972 Thank you!!

    • @cerisskies
      @cerisskies 4 роки тому +1

      @@benbuehler4972 Life saver, I've been going mad here

    • @spacedog2980
      @spacedog2980 3 роки тому

      @@benbuehler4972 thank you legend

  • @razorNeel
    @razorNeel 4 роки тому

    I started creating a game without having any c# knowledge last week based on your cube game. Now it has 7 proper levels, both keyboard and touch controls and a save file system.

    • @razorNeel
      @razorNeel 4 роки тому

      And now it has sound as well

  • @diablo4ever868
    @diablo4ever868 3 роки тому +3

    does anyone have a link to the audio manager download? looks like the link in the video is broken

  • @Vero2726-s8u
    @Vero2726-s8u 2 роки тому

    This is such a nice video, I'm starting with Unity now so I dint get much of the code part but I can see how great the Audio Manager is. Thank you so much !

  • @AboA7ma11
    @AboA7ma11 4 роки тому +4

    Use this function to adjust volume in runtime
    public void adjustvolume(float volume, string name)
    {
    sounds s = Array.Find(sounds, sound => sound.name == name);
    s.source.volume = volume;

    }

    • @AboA7ma11
      @AboA7ma11 4 роки тому

      @@flaymes make sure the other class name is "sounds"

    • @AboA7ma11
      @AboA7ma11 4 роки тому

      @@flaymes do adjustvolume("musicname", Slider.value);

    • @ptaroworm7887
      @ptaroworm7887 3 роки тому +1

      Dude, you're a life saver. This is exactly what I was looking for. Thank you

    • @Somewhere_sometime_somehow
      @Somewhere_sometime_somehow 2 роки тому

      @@AboA7ma11 I wanna use this but I'm stupid. What other class do you mean. You add this to the audiomanager right? I do have an array called sounds[ ] in my AudioManager script?

    • @AboA7ma11
      @AboA7ma11 2 роки тому +1

      @@Somewhere_sometime_somehow yeah just paste this into your audio manger as a method and use it as any other method in your script. just make sure when you call it you input a value or a variable as your volume :D

  • @pranavakp9960
    @pranavakp9960 4 роки тому

    You are the best teacher for coding games!!!

  • @gdzantaf6144
    @gdzantaf6144 5 років тому +6

    is there a way to cancel sounds(like music) by having some kind of stop method?

    • @gdzantaf6144
      @gdzantaf6144 5 років тому +1

      @@kadir9629 Thx

    • @vrstepper1204
      @vrstepper1204 3 роки тому

      @@gdzantaf6144 StopMusic.cs(10,19): error CS0103: The name 'Array' does not exist in the current context.

    • @khnuxsora
      @khnuxsora 2 роки тому

      @@gdzantaf6144 can you tell me how you did it?

  • @micnasr
    @micnasr Рік тому +2

    4 years later and I am still using the same Audio Manager that I used in 2019 lol

  • @maxageev3dart
    @maxageev3dart 4 роки тому +4

    How to adjust volume witch a slider in this AudioManager? Tried to add a new method for this but its dose not appears in functions while referencing AudioManager in a slider.
    public void AdjustVolume(float volume, string sound)
    {
    Sound s = Array.Find(sounds, item => item.name == sound);
    s.source.volume = volume;
    }
    How to make it work, please help ?

    • @sean6269
      @sean6269 3 роки тому

      Did you ever figure it out?

    • @maxageev3dart
      @maxageev3dart 3 роки тому

      Sorry man. Don't remember. That's was almost a year ago.(( I already probably lost the project where was using this thing.

    • @sean6269
      @sean6269 3 роки тому

      @@maxageev3dart I got it ;) he made another video on an options menu that was pretty similar to what I was trying to do

  • @KaiBeatbox0803
    @KaiBeatbox0803 4 роки тому

    damn I really like the way the Brackeys always give us the whole script and also teach us how to script yourself at the same time.

  • @omgtntlol
    @omgtntlol 5 років тому +10

    0:37 for some reason I heard "Lets add some silence" XDXDXD

    • @marcuionut6319
      @marcuionut6319 3 роки тому

      if I think about "Lets add some silence", I hear "Lets add some silence"
      but if I think about "Lets add some sounds", I hear "Lets add some sounds"
      Black magic

  • @marcusmorrow3900
    @marcusmorrow3900 5 років тому

    Excellent video! Thanks to you I learned more about classes and how they're used and about sound at the same time! multiple lessons in one video. Keep doing what you're doing your videos help out a lot.

  • @animemotivasiofficial
    @animemotivasiofficial 2 роки тому +3

    if your voice doesn't sound(Maybe because of different version), add code, s.source.Play()
    foreach(sounds in sounds)
    {
    s.source = gameObject.AddComponent();
    s.source.clip = s.clip;
    s.source.Play(); (Add This Code)
    s.source.volume = s.volume;
    s.source.pitch = s.pitch;
    }
    Hope you can help

  • @EduardoYukio
    @EduardoYukio 6 років тому +2

    Absolutely awesome tutorial, you go right to the point, speak clearly and very efficiently! Thank you very much!

  • @affe7130
    @affe7130 6 років тому +5

    How would I go about adding volume sliders to some of the sounds in my AudioManager?

    • @train_guy
      @train_guy 4 роки тому

      Check out Brackeys How to Make a Settings Menu in Unity Video and he explains how you can make an options menu and change the value of the volume
      ua-cam.com/video/YOaYQrN1oYQ/v-deo.html

  • @veno501
    @veno501 7 років тому +2

    Well done tutorial, well done! Even has some more of that delicious advanced stuff, and helps a lot in understanding HOW TO MAKE CLEAN CODE which is indeed important

  • @gaweringo
    @gaweringo 7 років тому +7

    am am trying to implement sounds into my games since 2 months, but unity is somehow not playing any of my audio files. Does anyone have an idea on how ti fix this problem?

    • @SasukeUchiha723
      @SasukeUchiha723 7 років тому +1

      im having the same issue

    • @Axedogames
      @Axedogames 7 років тому

      Have you the volume option at maximum ? Is unity no muted in your Volume mixer ?

    • @Axedogames
      @Axedogames 7 років тому +1

      Is your AudioSource near an AudioListenner ?

    • @d1nkum340
      @d1nkum340 4 роки тому +1

      check the mute audio button isnt checked, its next to gizmos

  • @Mechobree
    @Mechobree Рік тому

    Oh my god thank you for this video, I have a platformer project due tonight and the audio manager was giving me so much trouble!!
    This made it way more bearable :)

  • @Red_Dead_Chris
    @Red_Dead_Chris 6 років тому +4

    The link for the download do not work anymore :(

  • @ishaanchauhan3169
    @ishaanchauhan3169 7 років тому

    i love how you are going over each topic. thank u sm

  • @AlexVoxel
    @AlexVoxel 7 років тому +3

    Nice sound effects

  • @GemGameDev
    @GemGameDev Рік тому

    Many Thanks for that video!
    You cover the most important parts of sound in such a short time and do it so precisely!
    Hope you will upload new videos in the future again.

  • @LRMTB
    @LRMTB 4 роки тому +3

    i know this vid is quite old so probs no one will help, but how do you make it so that the music continues through the levels???? whenever i start a new level it starts the music from the beginning.

    • @shacharrodrigez7521
      @shacharrodrigez7521 4 роки тому +1

      just make the music go again when the scene open

    • @LRMTB
      @LRMTB 4 роки тому +1

      @@shacharrodrigez7521 yh the thing is i want it to continue from where it left off in the last scene

    • @cearaj405
      @cearaj405 4 роки тому +1

      idk if you already found it out but just watch everything after 12:11

    • @LRMTB
      @LRMTB 4 роки тому +1

      @@cearaj405 ah ok thanks lol

  • @fulgencejuniorlohore854
    @fulgencejuniorlohore854 3 роки тому +1

    You help me out buddy!!! Thanks for this tutorial! The Audio Manager is really useful!

    • @dcry1003
      @dcry1003 3 роки тому

      hey just wanna ask how come i cant edit my audio in my audio manager when i created a new clip inside of it with the audio put in it i cant edit the audio i can only edit the audio it its respective gameobject

    • @fulgencejuniorlohore854
      @fulgencejuniorlohore854 3 роки тому +1

      @@dcry1003 I got the same problem too. Even if the idea of creating an audio manager is cool, don't forget that since this tutorial has been done unity has undergone many updates. The problem comes from the output. Right that you a new audio clip but if the output is not configured, you wont got any sound.
      To solve this I did this:
      -Go to Window-Audio and Add "AudioMixer". From the AudioMixer window(upper right corner) you should see "Exposed parameters" hover it and read the text to know what it means.
      -In your Sound.cs do this: add "public AudioMixerGroup output;" as variable.
      -In your AudioManager.cs: add"s.source.outputAudioMixerGroup = s.output;" to the for each loop that go through your "public Sound[] sounds".
      if you want to play your audio from the AudioManager(disable your game object that holds your audio clip to make sure that it works and add your audio to the AudioManager) then do as he did in the video, like this:
      void Start()
      {
      Play("arion");
      }
      of course in AudioManager.cs.
      -Then in your "Assets" folder you should see some thing like "Master" that was not there. Drag it to your AudiManager output. Adjust pitch to at least 1, adjust volume and enter game mode to see how it works.
      But you should watch Brakeys tuto on how to create "settings" in games.

    • @dcry1003
      @dcry1003 3 роки тому

      @@fulgencejuniorlohore854 thats gonna be pretty hard specially if im gonna disable my gameobject just to test if the audio clip would work since some of those clips are from my player gameobject like death sound, jump, dash, attack, etc. Maybe like create a empty gameobject put the audio clips there and parent it to the player gameobject maybe that could work?

  • @AlineoRykkeErrel
    @AlineoRykkeErrel 6 років тому +11

    In case you want to make a transition between two musics when you start another one, I made two coroutine to do that ;) the old music fade and the new one start progressively at the same time
    private Sound sound;
    public void Play(string name) {
    StopAllCoroutines();
    if (sound != null) StartCoroutine(EndSound());
    sound = Array.Find(sounds, s => s.name == name);
    if (sound == null) {
    Debug.LogWarning("Music " + name + " not found.");
    return;
    }
    StartCoroutine(StartSound());
    }
    private IEnumerator EndSound() {
    AudioSource oldSound = sound.source;
    while (oldSound.volume > 0) {
    oldSound.volume -= 0.01f;
    yield return null;
    }
    oldSound.Stop();
    }
    private IEnumerator StartSound() {
    sound.source.Play();
    float volume = 0f;
    do {
    sound.source.volume = volume;
    volume += 0.01f;
    yield return null;
    } while (sound.source.volume

    • @Viralfanatics
      @Viralfanatics 3 роки тому

      Idk if you'd see this or reply but what is old sound here. I am a beginner so I can't really understand that.

    • @AlineoRykkeErrel
      @AlineoRykkeErrel 3 роки тому +2

      @@Viralfanatics Hey, oldSound is a copy of the music currently playing. This way, I can have the "old" music playing with the new one at the same time. And I can fade out the old sound to a volume of 0 and stop it to make a smooth transition between the 2 musics

    • @Viralfanatics
      @Viralfanatics 3 роки тому

      @@AlineoRykkeErrel Oh Thanks. I want my music to fade out as I change scenes and in the next one I want another track to fade in. I have been trying to figure it out for hours now and I haven't been successfull yet :')
      Can you help me with that?

    • @Viralfanatics
      @Viralfanatics 3 роки тому +1

      Nevermind. I figured it out. Thanks a ton. Your comment helped a lot!!

    • @AlineoRykkeErrel
      @AlineoRykkeErrel 3 роки тому

      @@Viralfanatics you're welcome haha, did you use DontDestroyOnLoad?

  • @chlasma
    @chlasma 3 роки тому +1

    this is so clean....so FREAKNING CLEAN!!!!!!!

  • @Ben-qn3py
    @Ben-qn3py 5 років тому +4

    I can Play music but I can't stop it. How do i do that?

    • @GeorgeWulfers_88
      @GeorgeWulfers_88 4 роки тому

      You would need to call Stop() on the audio clip.

    • @vrstepper1204
      @vrstepper1204 3 роки тому

      @@GeorgeWulfers_88 how please? AudioManager.instance.Stop("MyMusic"); does not work.

  • @8bytegaming139
    @8bytegaming139 6 років тому

    If I need to know something I usually go to Brackeys first, love all of these videos.

  • @ahmedsleem81
    @ahmedsleem81 5 років тому +3

    Thanks, but the link to Audio Manager is dead now

  • @kueyz5
    @kueyz5 2 роки тому +1

    If code is not working for you anymore, change name variable to _name (both in AudioManager and Sound), thats because Unity recently made that name shows the name of the gameObject and that breaks the code.

  • @rickschroevers2497
    @rickschroevers2497 5 років тому +4

    In some scenes i want the music to stop using a trigger but i dont really know how to do that. Is there a way to have some kind of 'Cancelmusic' method that will pause certain sounds? If someone could just type a bit of code under this comment that would be awesome! 😄

    • @hajperdev
      @hajperdev 4 роки тому

      public void StopPlaying(string sound){
      Sound s = Array.Find(sounds, item => item.name == sound);
      if (s == null){
      Debug.LogWarning("Sound: " + name + " not found!");
      return;
      }
      s.source.volume = s.volume * (1f + UnityEngine.Random.Range(-s.volumeVariance / 2f, s.volumeVariance / 2f));
      s.source.pitch = s.pitch * (1f + UnityEngine.Random.Range(-s.pitchVariance / 2f, s.pitchVariance / 2f));
      s.source.Stop ();
      }

    • @hajperdev
      @hajperdev 4 роки тому

      Somebody posted it there, it's the same but you just stop instead of play

    • @vrstepper1204
      @vrstepper1204 3 роки тому +1

      @@hajperdev StopMusic.cs(10,19): error CS0103: The name 'Array' does not exist in the current context
      \StopMusic.cs(10,30): error CS0103: The name 'sounds' does not exist in the current context
      Cant get this to work at all.
      I dont understand why : AudioManager.instance.Stop("Smile"); does not work when: AudioManager.instance.Play("Smile"); works...

    • @hajperdev
      @hajperdev 3 роки тому +1

      @@vrstepper1204 weird, I dont really remember how I made all of this but for modifying arrays im pretty sure you need to be using System libraries

    • @vrstepper1204
      @vrstepper1204 3 роки тому +1

      @@hajperdev problem is that you guys can code and we can not. So when nobody specifies that this code need to go into the SoundManager and not anywhere else, we get lost. I solved it by piecing things together and going through everything again. But it is often we newbies get confused because the well-meaning pro skips step that is second nature to them :)

  • @grouchylemur18
    @grouchylemur18 3 роки тому +1

    i love the fact he used is own voice going vroom into the car noise

  • @iZemash
    @iZemash 6 років тому +4

    Hi there everyone, I know that this is an old video, but what if I wanted to make a slider to control the volume if I made a settings menu.
    is there any way that I can hook this audio manager to an audio mixer?

    • @ms-9
      @ms-9 6 років тому +1

      same

    • @ms-9
      @ms-9 6 років тому +3

      okay I found a way :
      add :
      public AudioMixerGroup audioMixer;
      right before public Sound[] sounds;
      add :
      s.source.outputAudioMixerGroup = audioMixer;
      under the other s.source (volume, pitch, etc)
      assign your Master from the MainMixer in the editor and you're good !

    • @taragitaratayo2304
      @taragitaratayo2304 6 років тому

      Mano you are the champ! , would you happen to know how we can seperate the sounds into specifics , like fx , bg music etc , im thinking to create 3 sets of audio manager but that would be prolly a waste of code

    • @ms-9
      @ms-9 6 років тому +1

      Mikhail Opulencia you have to learn how the mixer works to do this. After looking this tutorial ua-cam.com/video/vOaQp2x-io0/v-deo.html
      you should be able to do it (I managed to create a fx volume slider and a music volume slider after this).

    • @ms-9
      @ms-9 6 років тому +1

      Well knowing how the mixer works was not enough I had to do some c# research you'll find

  • @nazdynate553
    @nazdynate553 5 років тому

    Brand new to your channel, and found this VERY informative! I'm a Pro Tool user making sfx and music, but was looking to learn some basic programming, and this was a nice gentle push into the realm of coding. Thanks, man!