Changing volume of the walking sound dynamicly in the game...

  • #1, by AkcayKaraazmakSunday, 11. February 2018, 23:20 2 years ago
    Hi mates, is it possible to change the volume of the walking sound dynamicly in the game. I want to change the volume according to the scenes.

    Cheers

    Great Poster

    438 Posts


  • #2, by sebastianMonday, 12. February 2018, 08:17 2 years ago
    Hey, 

    do you have one walking sound set inside the characters outfit or already use single step sounds inside the animation frames where the characters feet meet the ground?
    You could easily put some "if/else"  around the "playsound" action parts to play the sounds in different volume or even change the played sound for different locations. 

    This can come in handy, if you need to switch the walk sounds mid scene for example when the character walks from a dry ti a wet ground surface. For this you can use the action areas. 

    =) 

    ~Sebastian 

    Thread Captain

    2337 Posts

  • #3, by AkcayKaraazmakMonday, 12. February 2018, 08:45 2 years ago
    But how I can change the volume mate? I have couple of different walking sounds for different environments, I use "change walking sound of the character" comment. There is no volume control for it :\

    Great Poster

    438 Posts

  • #4, by trepnMonday, 12. February 2018, 11:04 2 years ago
    Checkout this tutorial. Here they play differerent sounds, but you can change that to different volumes.

    Newbie

    60 Posts

  • #5, by trepnMonday, 12. February 2018, 11:09 2 years ago
    Play the files with LUA

    local soundID = startSound('vispath:assets/footsteps.mp3')
    setSoundProperty(soundID,{volume=70})
    1
    2

    Newbie

    60 Posts

  • #6, by AkcayKaraazmakMonday, 12. February 2018, 12:13 2 years ago
    Thank you so much Trepn!

    Great Poster

    438 Posts

  • #7, by afrlmeMonday, 12. February 2018, 12:18 2 years ago
    I would definitely say Lua is probably the best way to go if you are wanting to dynamically change the footstep type & volume on a per scene basis as you will need Lua tables to organize the sounds/point of origin for each scene.

    As trepn says, you can play sounds with the openAL Lua function. Lebostein's tutorial that he linked would likely be a good place to start, though that's an action part solution only. If you want to dynamically control the balance & volume levels then Lua script is needed.

    -- example of a Lua table containing some footstep sounds
    sndz = {}
    sndz["wood"] =
    {
     "vispath:sounds/footsteps/wood_1.ogg",
     "vispath:sounds/footsteps/wood_2.ogg",
     "vispath:sounds/footsteps/wood_3.ogg"
    }
    sndz["metal"] =
    {
     "vispath:sounds/footsteps/metal_1.ogg",
     "vispath:sounds/footsteps/metal_2.ogg",
     "vispath:sounds/footsteps/metal_3.ogg"
    }
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14

    -- example of playing a footstep sound with a dynamic volume value
    startSound(sndz[Values["ground_type"].String][math.random(3)], {flags=1, volume = math.random(75, 100)})
    1
    2

    In the example above I've assumed that a value inside of the editor has had a string value written to it which will be used to determine the ground type - metal, wood, concrete, debris, stones, rock, fauna, etc. & from that we call a random number (technically we could dynamically get the total table index count for the table with Lua rather than manually declaring the number) & then we dynamically set the volume between 75 & 100 so that each time a sound is played, even if it's the same sound it will sound different because the volume level will be different.

    Balance is a lot more complicated to give an example of because it's highly dependent on what sort of perspective view point you use for your game. Traditionally 2D games tend to use the same perspective style for most scenes so they don't need to create tons of character animations from different perspective points. 3D is a lot different because the camera can change position. Anyway, the next thing is figuring out if the balance should be based on the characters/cameras position from a specific source point or whether the balance should be based on the characters position which means footsteps will always be centered, but all other sounds will be affected based where the character is from them.

    Imperator

    6846 Posts

  • #8, by AkcayKaraazmakTuesday, 13. February 2018, 01:22 2 years ago
    Thank you so much Lee! I think it will do the job!

    Great Poster

    438 Posts

Write post