135
collision_start(integer numDetected) {}
collision(integer numDetected) {}
collision_end(integer numDetected) {}
Events in the collision family are invoked in an object after an avatar or physical object collides with it.
collision_start() is triggered when the collision starts; collision() is triggered periodically
while the objects are colliding; collision_end() is triggered when the collision ends. Compare
to the touch() and land_collision() families of events in Chapters 2 and 7, respectively.
Additional documentation can be found on the SYW website.
numDetected — The number of objects or avatars that have collided.
Collisions are a nice, simple way to detect whether there's an avatar nearby, but the avatar will collide
with the object, and that may not be the effect you are after. However, because you can't simply make the
objects phantom so that avatars can walk through them without colliding (phantom objects don't trigger
collisions), another useful function is llVolumeDetect(), which can make the object phantom but still
trigger collision events when something enters the object.
llVolumeDetect(integer detect)
If detect is TRUE, the object becomes phantom but triggers collision_start() and
collision_end() events when other objects enter or leave the object. It will not trigger
collision() events. When FALSE, the object does not become phantom and thus can trigger all
three event types: collision(), collision_start(), and collision_end()
*
. This function
must appear in the root prim.
detect — Enables or disables phantom collision detection.
* The FALSE case makes nonphysical objects react to collisions as if they were physical. While useful, this
is undocumented behavior, so be careful if you use this feature.
In comparison to llSensorRepeat(), the volume detector is a lot less expensive in terms of
computational resources, and you don't need to worry about delay. (The sensor may not catch an object if it
moves too quickly through the sensor zone.) You can use any arbitrary object (any shape, size, etc) to hold the
volume detector. That's cool because llSensorRepeat() will sense only in conical slices from spheres.
Whether the sensor or the volume detector is better for your situation depends on a variety of
factors. Table 5.3 summarizes the most common situations.