How do I Change Audio Volume Using Lerp?

Get help using Construct 2

Post » Wed Jul 09, 2014 9:15 pm

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.
B
25
S
7
Posts: 79
Reputation: 2,267

Post » Thu Jul 10, 2014 9:14 am

Why don't you use the easyTween plugin and set it to value?
B
37
S
6
G
1
Posts: 301
Reputation: 2,865

Post » Thu Jul 10, 2014 10:51 am

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.
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Thu Jul 10, 2014 6:22 pm

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!
B
25
S
7
Posts: 79
Reputation: 2,267

Post » Thu Jul 10, 2014 10:49 pm

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 ;)
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, Blendi1223, dop2000, oosyrag and 50 guests