LlCollisionFilter: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
Wulfie Reanimator (talk | contribs)
No edit summary
Gwyneth Llewelyn (talk | contribs)
m Replaced <source> with <syntaxhighlight> (note: it won't work in early 2026 until LL fixes it *again*)
 
Line 21: Line 21:
|constants
|constants
|examples=
|examples=
Stop filtering:
*Stop filtering:
<source lang="lsl2">llCollisionFilter("", NULL_KEY, TRUE);</source>
<syntaxhighlight lang="lsl2" inline>llCollisionFilter("", NULL_KEY, TRUE);</syntaxhighlight>
Filter out all collisions:
*Filter out all collisions:
<source lang="lsl2">llCollisionFilter("", NULL_KEY, FALSE);</source>
<syntaxhighlight lang="lsl2" inline>llCollisionFilter("", NULL_KEY, FALSE);</syntaxhighlight>
 
This script, placed in a wearable object, detects a collision when the person wearing it collides with an object named "Post":
This script, placed in a wearable object, detects a collision when the person wearing it collides with an object named "Post":
* 1st instance :
* 1st instance :
Line 36: Line 37:
A prim named "Post" hits the scripted object or scripted prim, the collision will not be detected
A prim named "Post" hits the scripted object or scripted prim, the collision will not be detected


<source lang="lsl2">default
<syntaxhighlight lang="lsl2">default
{
{
     state_entry()
     state_entry()
Line 47: Line 48:
         llSay(0, "OUCH!");
         llSay(0, "OUCH!");
     }
     }
}</source>
}</syntaxhighlight>
|helpers
|helpers
|also_functions=
|also_functions=

Latest revision as of 14:16, 3 February 2026

Summary

Function: llCollisionFilter( string name, key id, integer accept );
0.0 Forced Delay
10.0 Energy

Sets the collision filter, exclusively or inclusively.

• string name filter for specific object name or avatar legacy name
• key id filter by group, avatar or object UUID
• integer accept TRUE only process collisions that match, FALSE instead excludes matches

If accept == TRUE, only accept collisions with objects name AND id (either is optional), otherwise with objects not name AND id
If name or id are blank they are not used to filter incoming messages (or you could say they match everything). If id is an invalid key or a null key, it is considered blank.

Caveats

  • Any call of llCollisionFilter in the same event as llVolumeDetect changing (not just being called, but actually moving from FALSE to TRUE or vice versa) will be disregarded (before or after), if the event handler previously called a user-defined function. See #SVC-2490
  • Damage caused by llSetDamage will still apply to a filtered avatar.
    • Consequently, the object will immediately die on collision with the avatar. (And kill the avatar their health reaches 0.)

Examples

  • Stop filtering:

llCollisionFilter("", NULL_KEY, TRUE);

  • Filter out all collisions:

llCollisionFilter("", NULL_KEY, FALSE);

This script, placed in a wearable object, detects a collision when the person wearing it collides with an object named "Post":

  • 1st instance :

an object named "Post" has several child prims named "Object" . The prim named "Post" hits the scripted object or scripted prim , the collision will be detected

  • 2nd instance :

an object named "Post" has several child prims named "Object" . A child prim named "Object" hits the scripted object or scripted prim, the collision will be detected

  • 3rd instance :

an object named "Object" has several child prims named "Post" . A prim named "Post" hits the scripted object or scripted prim, the collision will not be detected

default
{
    state_entry()
    {
        llCollisionFilter("Post","",TRUE);
    }

    collision_start(integer total_number)
    {
        llSay(0, "OUCH!");
    }
}

See Also

Events

•  collision_start
•  collision
•  collision_end

Functions

•  llPassCollisions
•  llVolumeDetect

Deep Notes

Signature

function void llCollisionFilter( string name, key id, integer accept );