How do I Change Audio Volume Using Lerp?

0 favourites
  • 5 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello and thanks for looking.

    I have an object that makes noise. I would like that noise to increase in volume as I get closer to it and decrease as I move away from it. I know there's positional audio & object audio options but the manual says these aren't supported in all browsers. So, I'm thinking Lerp is my answer. I've had limited success with Lerp in the past (I'm not as bright as I'd like to be )

    Does anyone know how I would go about achieving this? Thanks.

  • Why don't you use the easyTween plugin and set it to value?

  • This isn't very accurate since I don't know how to do the math based on the square distance, but it does increase the volume as you get closer to the audio source. You can fiddle with the values or remove the ^2 altogether for a linear interpolation.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Elios, thanks for the capx! I ended up testing the distance between my character and the water noise and adjusting volume accordingly. I'm curious if we came to the same conclusion mechanically.

    Thank you so much for the assist!

  • Well, for me it wasn't a conclusion so to say, I have used this before on some tests, you know, searching and experimenting in order to learn the engine and how to program with it. I just don't understand the math (and how they should be implemented within Construct) to emulate the square distance law (I think that the sound also drops over the square distance from the source)...

    Anyway, I'm glad that you find your solution

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)