Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Caculate how far away sound is

Author
Message
Stora tomtefar
20
Years of Service
User Offline
Joined: 15th Mar 2005
Location: Göteborg, Sweden
Posted: 27th Jun 2006 22:13 Edited at: 27th Jun 2006 22:14
Hellu.

I've got a little questen regarding 3Dsounds. Well, the only thing 3Dsound actually does is to fix the pan of the sound so it's being played in the left or inte the right speakre, true? Well, I would also like the sound to fade out when the player are traveling FROM the sound, and vice versa. I've tried to fix this by using this code:



I've used the calculation found i this tutorial:
http://developer.thegamecreators.com/?f=t02/bm_tutorial_7

The problem that I'm facing is this:
Of course when I'm getting to far away from the object (2), Volume# equals zero (Volume#=0), but as I'm getting further and furhter away, it starts to increase again! The most logic thing would be if the value would become negative, wouldn't it?

So I'm wondering; is there an easy way to calculate the distance between two objects by using the X- and Z-coordinates of them?
Thanks!

www.godhatessweden.com

My name, Stora_tomtefar, means "big santa claus" in swedish.
QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 27th Jun 2006 22:41
Yes, there's an easy way to calcualte 2D distances, which is to use the tutorial link you just posted. Of course, here is the formula you're supposed to use:


And here is your butchered version of that formula:


Notice how you add when the formula requires subtraction, and you also did not put parenthesis around the first two subtracted values, meaning that instead of (object position X(1) - object position X(2)) being squared, only object position X(2) is squared.

Here is the formula correctly applied to your objects:



Stora tomtefar
20
Years of Service
User Offline
Joined: 15th Mar 2005
Location: Göteborg, Sweden
Posted: 29th Jun 2006 23:43
Ahh, I see. Thank you! It works like a charm now

www.godhatessweden.com

My name, Stora_tomtefar, means "big santa claus" in swedish.

Login to post a reply

Server time is: 2025-05-25 06:13:48
Your offset time is: 2025-05-25 06:13:48