linch
New Member
Posts: 3
Posts: 3
|
Post by linch on Apr 28, 2023 11:42:24 GMT
I’m using Master Audio(just updated to 2022) in several of my projects and I love it.
I wonder if there is a way to stop one sound group instead of all sound groups. Here is my scenario:
I’m having a 2D flying bat that will fly up and down. I want the player to hear the flying sound of the bat when the distance between the bat and the player is lesser than 5. I have a script that will detect the distance between the bat and the player and will run MasterAudio.PlaySound(fly) when the bat is close enough to the player and will run MasterAudio.StopAllSound(fly) when the bat is away from the player. The idea is similar to ambiance sound but in 2D. My solution works fine when there is only one bat but if there are two bats in range, as soon as one bat flies out of the range, all flying sounds stop. Thus I wonder if I can stop one looping fly sound instead of all fly sounds in the sound group. Is there any way I can achieve this or if there is another workarounds? Thanks!
|
|
|
Post by DarkTonic Dev on Apr 28, 2023 13:38:05 GMT
Yeah, you can use MasterAudio.StopSoundGroupOfTransform, but you will need the "actor" Transform of the bat to pass in.
You can also use MasterAudio.StopAllSoundsOfTransform.
-Brian
|
|
linch
New Member
Posts: 3
Posts: 3
|
Post by linch on Apr 29, 2023 14:03:09 GMT
Hi there, thanks for the reply! I've tried that in the begining and after seeing your reply I tried again, still no luck. I write a simple script just to test here, it would be nice you can point out what I did wrong - maybe the problem is not with the code but with my understanding of MA or a bad setup.  
|
|
|
Post by DarkTonic Dev on Apr 29, 2023 14:40:15 GMT
It doesn't work because you didn't give Master Audio a transform when you played the sound.
You would need to use one of the methods that has "Transform" in the name, such as MasterAudio.PlaySound3DAtTransform
|
|
linch
New Member
Posts: 3
Posts: 3
|
Post by linch on Apr 29, 2023 17:34:45 GMT
It's working! Thank you very much! Thanks to your quick reply, I can turn in my game on time! 
|
|
|
Post by DarkTonic Dev on Apr 30, 2023 14:38:38 GMT
No problem.
|
|