llTriggerSoundLimited(string sound, float volume, vector tne, vector bsw)
Plays a transient
sound NOT attached to an
object with its audible range limited by the
axis--aligned
bounding box defined by
tne (top-north-east) and
bsw (bottom-south-west). The sound plays from a stationary
position located at the center of the object at the time of the trigger. There is no limit to the number of triggered sounds which can be generated by an object, and
calling llTriggerSound does not affect the attached sounds created by
llPlaySound and
llLoopSound. This is very useful for things like
collision noises, explosions, etc. There is no way to stop or alter the
volume of a sound triggered by this function.
It is polite to use this function where ever possible, especially to prevent your sounds spilling over on to your neighbor's
land. Alternately, use the normal non-limited sound functions and exceedingly small
volume settings, like
0.05, so that the sound is highly localized, though this is probably less useful for explosions, etc.
The values for
tne and
bsw are in
region local coordinates. So, the points
tne and
bsw describe a box in the
world.
This box is unrelated to the scripted object's position. An
avatar standing in this box will be able to hear the triggered sound (if they could hear it if it was played with just
llTriggerSound. That is, they are not too far from the object triggering the sound and it is not too quiet). An avatar standing
outside the box will not hear the sound.
Note: avatars walking into the box after the sound is triggered (no matter the length of the sound) will not hear the sound.
To get the
values for
tne and
bsw, you can use the following method:
- Create a cube that is the bounding box you want (you can make it phantom and semi-transparent to make things easier).
- Create a small sphere (doesn't matter what it is, except for the purposes of this description) centered on one corner of your cube. Take note of its position from the edit window (call this vector1).
- Create another small sphere centered on the diagonally opposite corner of your cube. Take note of its position from the edit window (call this vector2).
- We now have two vectors, vector1 and vector2, for each of x, y, and z. Put the larger value in the vector tne, and the smaller value in bsw.
For example, if
vector1 was
<100,50,20> and
vector2 was
<10,75,60> then
tne would be
<100,75,60> and
bsw would be
<10,50,20>.
If you just want your scripted object's sounds not to spread too far, use this method:
This makes it so that people will only hear the sound if they're within around 10 meters, give or take some. Objects like slot machines would greatly benefit from this.
Q: Is there a way to have sound played so that only a specific agent can hear it?
A: llTriggerSoundLimited(sound, volume, llGetPos(), llGetPos()) in an HUD attachment will do the trick.
A: llPlaySound() will also do this in a hud attachment, and it'll be nondirectional.
You can also target a specific avatar in code like this:
This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.
Functions | Sound