Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting Collisions with specific objects?

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
12-01-2005 11:21
How would I go about detecting which of 3 different objects a wandering prim of mine collides with?

do I use the llDetectedName(0) call to check for a specific object's name? Since I'm intending to use this in 5 similar prims that are competing to touch the objects, how would I deal with the scenario that it collides with the target object and another competing prim at the same time? My experience with checking for multiple things in a loop has shown to delay the script's time, sometimes a significant amount which.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
12-01-2005 12:48
One easy way of doing this is using three scripts, each with a collision filter set to accept collisions with one of the three target objects. The only way to do it reliably with only one script would be to use a loop - something you dont want to do.

Example:
CODE

default {
state_entry() {
// Only accept collisions with objects named "Foo"
llCollisionFilter("Foo", NULL_KEY, TRUE);
}
collision_start(integer totalNum) {
llOwnerSay("Collided with " + llDetectedName(0));
}
}


See:
llCollisionFilter
Collisions
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm