How to change footstep volume while slowing down in velocity.length() ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Wodsobe Dobe

My footstep sound playing is controlled by animation, and whenever my character transitions from movement to idle, the footsteps remain the same volume. I was wondering if I could use velocity.length() to change the volume or if there is another way. Thanks!

:bust_in_silhouette: Reply From: rakkarage

if you are just trying to get some variation in the steps:
wrapping your sound files with this can make them all sound a little different each time they play

This is helpful to the sound, and i thank oyu for that, but what i was looking for was the volume increasing or decreasing when i transition from the idle to movement animations.

Wodsobe Dobe | 2020-07-25 05:48

Have the volume of the sound changed with the increase/decrease of velocity.length() by changing the volume_db property of the AudioStreamPlayer. Map the length of the velocity to the magnitude of the volume_db property where necessary.

Ertain | 2020-07-25 06:38

How would I do that?

Wodsobe Dobe | 2020-07-25 08:05

If the length of the velocity is between 0.0 and 1.0 (something akin to a percentage), multiplay the maximum volume by this length and assign it to volume_db. The actual volume value, though, may have to be between a certain range, though, as detailed in this section on audio buses.

Ertain | 2020-07-26 07:31

You can use the range_lerp() and inverse_lerp() methods for this. If you need more control over the curve, you can use a Curve resource (created in the editor or in the script) and load it in the script. =

Also, keep in mind decibels aren’t linear. You’ll probably want to use linear2db() along the way.

Calinou | 2020-07-28 14:53