Sounds volume relative to distance

Get help using Construct 2

Post » Thu Feb 20, 2014 1:28 pm

Hey all !

I'm trying to make a sound volume relative to the distance between the source and the listener, I can't find informations about that, at the moment the manual is broken and some precious topic are missing !

So, I'm on a big layout, I want the player to hear sound volume based on how far he's from the source, for example an ennemy firing 1000 pixels aways, the volume must be low and as I get closer from the source the volume is higher.

Any ideas on this ?

Thanks !
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Thu Feb 20, 2014 3:21 pm

If you just want volume, set the volume to some multiple of the distance every tick (like 0.2*distance), but I assume you would want panning, too. In the audio section don't just play sound but choose the "play sound at position" option. Then you can set the epicenter, the rolloff, everything. It will also pan left/right relative to whatever you set. I typically do just the center of the screen, but you can do it relative to your player, for instance, if you want.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Thu Feb 20, 2014 3:29 pm

The PDF manual is here: https://www.scirra.com/manual.zip
See if that still works.
B
71
S
21
G
231
Posts: 3,689
Reputation: 129,354

Post » Thu Feb 20, 2014 3:34 pm

C-7 wrote:If you just want volume, set the volume to some multiple of the distance every tick (like 0.2*distance), but I assume you would want panning, too. In the audio section don't just play sound but choose the "play sound at position" option. Then you can set the epicenter, the rolloff, everything. It will also pan left/right relative to whatever you set. I typically do just the center of the screen, but you can do it relative to your player, for instance, if you want.



Thanks for your answer, I tried the play sound at position, but I don't get it to work. The sound have the same volume, and there is no pan left/right. I'll try to make an example capx soon.
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Thu Feb 20, 2014 5:08 pm

See the built-in positioned sounds example. You need to set a listener object for it to work.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Thu Feb 20, 2014 8:09 pm

I'm using a listener, the sound is well positionned... And I was missing the Audio Properties, thanks manual, I'm lost without you !

Ty all !
B
39
S
15
G
5
Posts: 295
Reputation: 6,089


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests