Hey,
I wrote a nice little 3D sound function for a game I am working on and just thought I would share.
You have to set the maximum hearing distance, and the maximum volume, but it does everything else.
You put in the 3D sound number, the source, and the listener, and it will calculate the volume based on the distance, and size of the source and listener. It also uses the built in sound positioning function.
The outcome is pretty nice, but needs a bit more fine tuning.
Also, I recommend putting a position listener command in your loop if your listener dosent change
Variables to set:
maxsounddistance#
maxsoundvolume#
function playsound(soundno, source, listener, startpos)
sounddistance# = distance(object position x(listener), object position y(listener), object position z(listener), source)
sourcesize# = object size x(source) * object size y(source) * object size z(source)
listnersize# = object size x(listener) * object size y(listener) * object size z(listener)
soundvolume# = (((maxsounddistance#-sounddistance#)/maxsounddistance#)*(sourcesize#/listnersize#))*100
if soundvolume# < 0 then soundvolume# = 0
if soundvolume# > maxsoundvolume# then soundvolume# = maxsoundvolume#
position sound soundno, object position x(source), object position y(source), object position z(source)
position listener object position x(listener), object position y(listener), object position z(listener)
set sound volume soundno, soundvolume#
play sound soundno, startpos
endfunction
Matt