Fade in/out individual sounds.
geoascencio
Member, PRO Posts: 73
okay so i have a game where enemies makes breathing sound and footstep sounds, so the closer i get to the enemies, the louder the foot steps and breathing sounds get. If i mess with game.audio.soundvolume it lowers all the sounds of the game. How can i fade in/out individual sounds. my enemies track the main character x/y location, i got that far, but don't know how to fade in/out the enemies sound.
Comments
The volume of each sound can be an expression, so use that, in the Play Sound action.
Armelline did a great video on this @geoascencio - Here you go...
@Japster I've followed the video tutorial but when the scene starts, the audio is in full volume. It isn't until the actor gets to the point where you should start hearing the audio (the point where the audio would be at it's lowest volume), then it's starts working perfectly and starts acting the ways it's supposed too. This only happens when the scene starts. I'm working in the windows version of game salad, so maybe that might be the problem, but maybe I'm doing something wrong.
@geoascencio Can you show us the logic you're using to control the sound volume? It sounds like maybe the sound is being triggered before the attribute that controls its volume is set. I just tested and can confirm that attributes are applied to the sound volume immediately upon scene start, so it's possible the volume control is in an actor higher on the layer list than the sound?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline thank you so much for helping! I'm trying to figure out how to post images on the forum to show you what i got.
https://imgur.com/PWKG6in
https://imgur.com/8F4DZPw
I think the problem is that you start too far, and at those distances the calculation you use gives a negative number. As that is an invalid entry, the sound volume will stay at 1 instead. Later on, if you reach that distance, the volume has already been reduced, so it stays at that instead, and it works.
I'd suggest wrapping the whole expression into a MAX function --> max(0,[your calculation])
That way, the expression will never give you a number lower than zero and it should all work fine all the time.
@pHghost IT WORKS!! The MAX function did it! @Japster @Armelline thank you guys so much!
Glad you got the problem sorted! @pHghost was too fast for me
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Glad to help. Good luck with the game!