Fade in/out individual sounds.

geoascenciogeoascencio 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

  • pHghostpHghost London, UKMember Posts: 2,342

    The volume of each sound can be an expression, so use that, in the Play Sound action.

  • JapsterJapster Member Posts: 672

    Armelline did a great video on this @geoascencio - Here you go...

  • geoascenciogeoascencio Member, PRO Posts: 73

    @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.

  • ArmellineArmelline Member, PRO Posts: 5,354
    edited October 2017

    @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?

  • geoascenciogeoascencio Member, PRO Posts: 73
    edited October 2017

    @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

  • pHghostpHghost London, UKMember Posts: 2,342

    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.

  • geoascenciogeoascencio Member, PRO Posts: 73

    @pHghost IT WORKS!! The MAX function did it! @Japster @Armelline thank you guys so much!

  • ArmellineArmelline Member, PRO Posts: 5,354

    Glad you got the problem sorted! @pHghost was too fast for me :D

  • pHghostpHghost London, UKMember Posts: 2,342

    Glad to help. Good luck with the game!

Sign In or Register to comment.