|
Post by hipsterdufus on Dec 29, 2021 1:34:32 GMT
Hey there. I have an ambient sound component in my scene that triggers when the camera gets near. Problem is the rigidbody follower radius is set to 10 so it triggers from further away than I'd like. I can shink the trigger area as a workaround but it'd be nicer if I can set the follower radius to 1 so I can see in the scene exactly where the trigger will happen. I couldn't find any way to set the follower radius - it's not a prefab and seems to be generated by master audio at runtime with no configuration options. Any way to do this?
|
|
|
Post by DarkTonic Dev on Dec 29, 2021 2:48:42 GMT
You don't set the radius, it's set to what it is for a reason. At runtime, it's set to the Max Distance of the Audio Source of the Sound Group that is to play. Therefore it only triggers if it would be audible. That's also why there are controls to set the Min and Max Distance of the Sound Group's Audio Sources in the Ambient Sound Inspector. So, if you want to tweak the radius, you tweak the Max Distance.
-B
|
|
|
Post by hipsterdufus on Dec 29, 2021 21:00:15 GMT
Alright thanks. I've been trying to get this to work still. I can get it to work but not exactly how I'd like. My game is a top-down 2D game. All I need is for the ambient sound to play when the player comes within a certain distance and ramp up to a maximum volume if the player gets within another closer distance. So I've set the Spatial Blend rule to 3D on the Sound Group (I think that's needed for ambient sounds). Or should I select "Use curve from audio source"? A related question I have is this - I have various objects in the game that emit sounds. For example chickens that cluck. Currently I'm triggering the sound once in a while in code by calling MasterAudio.PlaySound3DAtTransformAndForget like this: MasterAudio.PlaySound3DAtTransformAndForget("Chicken_Cluck", transform); But it doesn't seem to play. When I set the Sound Group to 2D it works but then I'll hear the chicken clucks with the same intensity even if they're a mile a way in the scene correct? So I don't want that. Another slight issue is my Audio Listener being on my camera. My camera has a z position of -10 so it throws off the distance depending on what z pos everything else is. Is there any way to use a 3D sound and ignore z-positions or is that something I just need to deal with? In the Master Audio Group component if I choose "When Actor In Audible Range" for Group Play Rule, is that generally what I need to accomplish what I'm doing? Another issue is when I select Max Distance 20 for my Audio Source Template and click Apply Audio Source Template to All, I get an exception in the unity console so I'm not sure it's actually applying. It says: MissingReferenceException: The variable audioSourceTemplates of MasterAudio doesn't exist anymore. You probably need to reassign the audioSourceTemplates variable of the 'MasterAudio' script in the inspector. Here is a screen cap: imgur.com/a/EnMFaw8
|
|
|
Post by DarkTonic Dev on Dec 29, 2021 22:00:24 GMT
You can use a custom curve if you like, but it's whatever you prefer. Normally setting the min and max distance is sufficient.
When "it doesn't seem to play", that's because at the distance your actor (chicken) is from the Audio Listener, it's inaudible. So you'll need to increase your Max Distance for the Sound Group until you can hear it enough. You can do that in bulk by applying Audio Source Templates to multiple selected Sound Groups at the Master Audio Mixer section. There are several included at different Max Distances, or you can make your own.
To check to see if it's actually playing, turn on "Log Sounds" for the Sound Group and watch the Console window output. If the sound doesn't play (there are about 15 reasons why that may happen), it will tell you exactly why.
Having the Audio Listener on your camera is pretty normal. Yes its Z position will be used in calculating the distance, which is desired.
If you choose "When Actor In Audible Range", then it won't bother to play the sound if the actor is further away from the Listener than Max Distance.
Sounds like you have broken AudioSourceTemplates in the Master Audio Game Object. You will need to switch the Inspector to Debug mode, and re-assign all the Audio Source Templates from the folder.
-Brian
|
|
|
Post by hipsterdufus on Dec 31, 2021 1:35:33 GMT
Thank you. I decided to just use 2D sounds and forget about a nice ramp up depending on how far away the player is. I think a binary play or not play is usually how it's done for 2D games. Not sure how I broke the AudioSourceTemplates, maybe it's broken out of the box? Some of the prefabs were indeed missing.
Another question - when changing songs in a playlist I'd like to fade out the current song, wait a few seconds, then begin playing another song. Is there an easy way to coordinate this? It seems like my only option is to crossfade where it fades in the second song as the first one is fading out but I don't want that. I want a more slow transition without any overlap. Just wondering if there's an easy way.
|
|
|
Post by DarkTonic Dev on Dec 31, 2021 2:39:31 GMT
Correct. If it's a 2.5D game you might want 3D sound. It's not broken out of the box and easily fixed in Debug mode. I've downloaded it many times from the Asset Store and never saw that problem. As far as silence between songs that's not an option we offer. You could do it by basically disabling auto-advance on the Playlist Controller, and subscribing to the SongFinished event, then doing whatever you like when the event occurs, such as waiting X seconds then playing another song. There's an example of using a different Playlist Controller event on this page near the bottom: www.dtdevtools.com/docs/masteraudio/TriggeringAudioCoding.htmThere is a very rudimentary script included called DelayBetweenSongs.cs that you can try as well, which may not require much or any coding. -B
|
|