|
Post by cptscrimshaw on May 28, 2021 0:34:54 GMT
First off, I absolutely love MasterAudio; I've been using it for a while now and it just works! I'm setting the sound group through code for one of my AmbientSound components, and for whatever reason it's setting the mix/max distance back to the default (min 10, max 100). Is there a way that I can set the min/max distance in my script after I change the sound group? I assume there is a simple solution; I just haven't found it! How I'm changing the sound group: this.GetComponent<AmbientSound>().AmbientSoundGroup = craftingSound; ibb.co/b2JmN88Thanks!
|
|
|
Post by DarkTonic Dev on May 28, 2021 2:02:20 GMT
The script creates a trigger with the same radius as the settings in that when the Game Object becomes enabled. You will need to make sure it's set to whatever you want before that OnEnabled code runs. You could try making sure your script runs before AmbientSound by using the Script Execution Order window in Unity. That might do it. I'll bet it currently runs after. Otherwise it will have no effect no the trigger and won't do what you want.
-Brian
|
|
|
Post by cptscrimshaw on May 28, 2021 13:37:23 GMT
That makes sense. How would I go about changing the Min/Max distance in code before enabling the component? I can't seem to access min/max distance within the AmbientSoundGroup through code.
|
|
|
Post by DarkTonic Dev on May 28, 2021 15:08:10 GMT
Yeah, actually those are the Min Distance and Max Distance fields on all the Audio Sources in all the Variations of the Sound Group you have selected to play that are being modified when you change the min/max distance fields in the Inspector. So that's where you'd need to modify. Since you'd likely need your script to run before AmbientSound, MasterAudio and SoundGroupVariation classes. Looking at the Script Execution Order screen, you might as well run before everything Master Audio related. Try -90.
|
|
|
Post by cptscrimshaw on May 28, 2021 16:38:10 GMT
I don't see any min/max distance controls in the Audio Source or Sound Group Variation script. Apologies if I'm missing something simple (see screenshot). ibb.co/8gGmFPT
|
|
|
Post by DarkTonic Dev on May 28, 2021 16:46:09 GMT
It's in the 3D Sound Settings you have collapsed there in the Audio Source.
|
|
|
Post by cptscrimshaw on May 28, 2021 17:19:07 GMT
Worked perfectly (and didn't have to change the script execution order) Thanks so much for the fantastic support!
One more question: After a set amount of time, I disable the AmbientSound component and destroy the AudioTransformTracker:
this.GetComponent<AmbientSound>().enabled = false; Destroy(this.GetComponent<AudioTransformTracker>());
However, when I go back inside the range, it recreates the AudioTransformTracker. How would I prevent this from happening? I'll want to reenable the AmbientSound component at some point, but only when I call it from script.
|
|
|
Post by DarkTonic Dev on May 29, 2021 3:10:48 GMT
I don't understand why you're doing that. AmbientSound is meant to work perfectly even if it comes in and out of range many times or becomes disabled and re-enabled later. Is it not working properly? You shouldn't need to destroy the Tracker manually.
-B
|
|
|
Post by cptscrimshaw on May 29, 2021 15:39:21 GMT
I have a crafting station where the ambient sound effect is generally turned off when the crafting station isn't in use. And when it's in use, I set the audio clip for the ambient sound effect to play and turn it on. When the crafting is done, I'd like to turn off the ambient sound until something new is crafted. Hopefully that makes sense. Any ideas on the best way to implement this?
|
|
|
Post by DarkTonic Dev on May 29, 2021 16:50:59 GMT
Try just disabling the game object with Ambient Sound script on it. I think that would do it.
|
|
|
Post by cptscrimshaw on May 29, 2021 20:19:22 GMT
Worked perfectly - thanks so much!
|
|
|
Post by DarkTonic Dev on May 30, 2021 3:48:39 GMT
No problem.
|
|