Nice video! A simple dictionary of that you create at runtime feels much easier to read. Also be careful with having all your sounds in a single script, specially on mobile, because if the game grows, this means having all the game audio loaded into memory from the start, even sounds that you don't even need in the current scene
this is such a good tutorial, seriously so helpful! love how you structure the video and actually show the features you're talking about at the START of the video. it helps so much to know if this tutorial is something i'm looking for. super easy to follow! thanks for sharing this for people like me to learn and follow along for free!!!
Nice! Btw one thing i like to add with audio players is random pitch - usually storing it as Vector2 (so X/Y are min/max, 1f/1f as default) and change AudioSource's pitch with random range when play function is called. Small but fun thing, however unsure how it affects perfomance in any case..
This is fine for managing 2D sounds - like in your side scroller example - but what about 3D sounds? How does this deal with sounds that are localized to objects moving through a 3D scene? When an airplane flies over for instance, the sound should get louder and move across the scene as it approaches, and Doppler shift as it passes. I just find it easier to put a sound source on the moving object, and let the Unity audio manager handle it, than to manually process each sound clip to fake all of that. So this approach may not work as shown in every use case.
That’s an incredibly crucial distinction to make. This particular sound manager utilises one shot/instant sounds at a specific volume. This script can be tweaked to include a Transform and 3D float parameter so it spawns a gameobject with an audio source attached under the parent Transform. Then start a coroutine that lasts until the end of the audio clip duration, then it destroys itself.
xD. I should ask the developer to add more features! Its selling point is it’s completely customisable. You can flicker colour, flicker materials, add sound, and trigger events all in just one state. You can add an infinite amount of these states that do anything you want. I genuinely use this asset in most of my projects because of how versatile it is! Would recommend checking out the tutorial video on the Unity Asset Store to see all the features :)
The easiest way I found for stuff like this is to trim the clip using "Audacity" just drag and drop your audio in. You can loop it, cut it, past it, duplicate it, merge it - whatever. Then just export it straight back into your asset folder. Done
You can simply create different methods for the manager that will look for different sounds in different ways. Example: playRoundRobin() playIndex() playName() playClip() Etc. The implementation is quite simple. Round robin needs only to have the index increment and then modulo the list size. Index needs an index integer (might wanna modulo the list size just in case) Name would want to find the clip name within the array (slow but you can make it so that it keeps it in inventory until told to get a different one, to make it O(1) on subsequent calls Clip would just make it so it doesn't read the sound manager's list at all and just plays what you give it, OR you could have it check if the clip is contained within the manager and play it if it is.
Nice video but i have a problem, How can I lower the volume of the walking sound independently?, my walking sound is very loud and I would like to decrease it without altering the others
I actually found this exact issue! On the GitHub link, you can now change each sound volume in the Unity inspector, as well as its audio mixer. So the sound manager shown in the video is a little bit outdated.
Although I see that the fix was implemented on the code, I do think, as an audio producer first and foremost, that it's best to properly batch normalize the audio on audacity before trying to implement it (maybe even slightly mastering it as well). It's generally better practice to have every sound file be uniformly functional from the get go than tweaking each individual sound.
for anyone making a 3D game, specifically XR, find another solution. this is great for small scale games, and some parts of it are applicable to larger projects. but imo, its not the greatest solution for something like an FPS, RPG, dungeon crawler, rogue-like, etc.
100%. The only prerequisite is the Play() method can not have more than 1 parameter. Could potentially create a scriptable object which holds Sounds enum and Volume, then pass in that.
Yes, I do. 😄 That's what happens when you learn something new. It was a way I could think of to play five sounds at the same time for one object. But now I will try this way.
This SoundManager is optimised for event-based sound effects. Such as playing a sound when criteria are met. For background music, I have a couple of suggestions. 1. Create a separate audio source and set it to looping. When the music needs to be triggered, call AudioSource.Play() and AudioSource.Stop() when it needs to stop. 2. Change the play method to SoundManager.Play(Sounds sound, float volume, bool looping). Then if looping is true, create a Coroutine which calls SoundManager.Play() again after the duration of the audio clip. Of course with this way, you’ll need a way to stop the looping, so there’ll need to be a new Stop() method which interrupts the Coroutine. I would strongly recommend #1. Unless you are looking to use the SoundManager script to manage all the sound/music in your project. I think the best way is a hybrid approach.
Nice video! A simple dictionary of that you create at runtime feels much easier to read. Also be careful with having all your sounds in a single script, specially on mobile, because if the game grows, this means having all the game audio loaded into memory from the start, even sounds that you don't even need in the current scene
Is there no way to replace the audio clips with pointers to them until a given condition is hit?
Man, I didn't know I could reference instanced non static methods that way. Works with variables too I like that. You taught me much today Senpai.
that senpai part is so cringe
this is such a good tutorial, seriously so helpful! love how you structure the video and actually show the features you're talking about at the START of the video. it helps so much to know if this tutorial is something i'm looking for. super easy to follow! thanks for sharing this for people like me to learn and follow along for free!!!
Thank you so much!!
Thank you mate! This is definitely a manager I am going to add in my game and the future ones! Big up to you 🙌
looks cool. definitely be using it
Nice!
Btw one thing i like to add with audio players is random pitch - usually storing it as Vector2 (so X/Y are min/max, 1f/1f as default) and change AudioSource's pitch with random range when play function is called.
Small but fun thing, however unsure how it affects perfomance in any case..
That is a great idea! It would definitely make the sounds feel more authentic.
Learned a couple of neat tricks here. Thanks for the helpful video!
This is fine for managing 2D sounds - like in your side scroller example - but what about 3D sounds? How does this deal with sounds that are localized to objects moving through a 3D scene? When an airplane flies over for instance, the sound should get louder and move across the scene as it approaches, and Doppler shift as it passes. I just find it easier to put a sound source on the moving object, and let the Unity audio manager handle it, than to manually process each sound clip to fake all of that. So this approach may not work as shown in every use case.
That’s an incredibly crucial distinction to make. This particular sound manager utilises one shot/instant sounds at a specific volume. This script can be tweaked to include a Transform and 3D float parameter so it spawns a gameobject with an audio source attached under the parent Transform. Then start a coroutine that lasts until the end of the audio clip duration, then it destroys itself.
This seems really good, but I think the soundlist step, if not the enum should be scriptable objects.
Yeah, an array of scriptable objects would also work.
Nice video great Sound Manager script and explanation
this is awesome, i wish i knew this earlier! you earned a sub :)
I FOUND A FUCKING GEM THANK YOU GEM
The light flicker asset is simply a spotlight that dims on and off. :} 😅
xD. I should ask the developer to add more features! Its selling point is it’s completely customisable. You can flicker colour, flicker materials, add sound, and trigger events all in just one state. You can add an infinite amount of these states that do anything you want. I genuinely use this asset in most of my projects because of how versatile it is! Would recommend checking out the tutorial video on the Unity Asset Store to see all the features :)
whats the success thing
how do i hace to make it work?
Why not use Scriptable Objects? Sounds lists in scriptable objects. Every characters gets it's own sound list.
Depending on application. This is more generic, and requires fewer additional assets as overhead.
You're a genius
how can i change the time where my sounds start , for example if i want to Play a sound but starting at 2 seconds in the sound not from the start .
The easiest way I found for stuff like this is to trim the clip using "Audacity" just drag and drop your audio in. You can loop it, cut it, past it, duplicate it, merge it - whatever. Then just export it straight back into your asset folder. Done
What if i don't want to choose a random sound and just want to have multiple i can choose from?
You can simply create different methods for the manager that will look for different sounds in different ways.
Example: playRoundRobin()
playIndex()
playName()
playClip()
Etc.
The implementation is quite simple.
Round robin needs only to have the index increment and then modulo the list size.
Index needs an index integer (might wanna modulo the list size just in case)
Name would want to find the clip name within the array (slow but you can make it so that it keeps it in inventory until told to get a different one, to make it O(1) on subsequent calls
Clip would just make it so it doesn't read the sound manager's list at all and just plays what you give it, OR you could have it check if the clip is contained within the manager and play it if it is.
Nice video but i have a problem, How can I lower the volume of the walking sound independently?, my walking sound is very loud and I would like to decrease it without altering the others
I actually found this exact issue! On the GitHub link, you can now change each sound volume in the Unity inspector, as well as its audio mixer. So the sound manager shown in the video is a little bit outdated.
@@SmallHedgeHQ Oh, ok i'll try it
Although I see that the fix was implemented on the code, I do think, as an audio producer first and foremost, that it's best to properly batch normalize the audio on audacity before trying to implement it (maybe even slightly mastering it as well). It's generally better practice to have every sound file be uniformly functional from the get go than tweaking each individual sound.
for anyone making a 3D game, specifically XR, find another solution. this is great for small scale games, and some parts of it are applicable to larger projects. but imo, its not the greatest solution for something like an FPS, RPG, dungeon crawler, rogue-like, etc.
Could you refactor this to use unity events?
100%. The only prerequisite is the Play() method can not have more than 1 parameter. Could potentially create a scriptable object which holds Sounds enum and Volume, then pass in that.
@@SmallHedgeHQ In order to keep the sound enum and volume would have to be set dirty between plays
Wait. People do that? Make a sound source for every sound? What?
You have got to be joking right?
Yes, I do. 😄 That's what happens when you learn something new. It was a way I could think of to play five sounds at the same time for one object. But now I will try this way.
FMod the best!!!
tbh just used first part of video🤣
Meh. just use scriptable objects.
can this system play background music while playing another sound effects using one audio source !
This SoundManager is optimised for event-based sound effects. Such as playing a sound when criteria are met. For background music, I have a couple of suggestions.
1. Create a separate audio source and set it to looping. When the music needs to be triggered, call AudioSource.Play() and AudioSource.Stop() when it needs to stop.
2. Change the play method to SoundManager.Play(Sounds sound, float volume, bool looping). Then if looping is true, create a Coroutine which calls SoundManager.Play() again after the duration of the audio clip. Of course with this way, you’ll need a way to stop the looping, so there’ll need to be a new Stop() method which interrupts the Coroutine.
I would strongly recommend #1. Unless you are looking to use the SoundManager script to manage all the sound/music in your project. I think the best way is a hybrid approach.