Skip to content

Touch

Clicking an object raises touch events in its scripts, and the detected functions tell who touched, which prim and exactly where. Touch needs no permission. Part of the Input feature.

Concepts

Functions and events

eventtouch_start(integer num_detected)
eventtouch(integer num_detected)
eventtouch_end(integer num_detected)
integerllDetectedTouchFace(integer index)
vectorllDetectedTouchST(integer index)
integerllDetectedLinkNumber(integer number)
llPassTouches(integer pass)
llSetClickAction(integer action)
llSetTouchText(string text)

Scripting Details

eventtouch_start(integer num_detected)
Triggered when an avatar first touches the object. Passes num_detected, representing the number of touching agents.
eventtouch(integer num_detected)
Triggered continuously while an avatar touches the object. Passes num_detected, representing the number of touching agents.
eventtouch_end(integer num_detected)
Triggered when an avatar stops touching the object. Passes num_detected, representing the number of touching agents.
integerllDetectedTouchFace(integer index)
Returns the integer index of the face clicked by the avatar in the touch event specified by index.
vectorllDetectedTouchST(integer index)
Returns the surface coordinates (<s, t, 0.0>) where the prim was touched, specified by index. X and Y contain the horizontal (s) and vertical (t) face coordinates, typically in the interval [0.0, 1.0]. Returns TOUCH_INVALID_TEXCOORD if coordinates cannot be determined.
vectorllDetectedTouchUV(integer index)
Returns the texture coordinates (<u, v, 0.0>) where the prim was touched, specified by index. X and Y contain the horizontal (u) and vertical (v) texture coordinates, typically in the interval [0.0, 1.0] (affected by repeats and rotation). Returns TOUCH_INVALID_TEXCOORD if coordinates cannot be determined.
vectorllDetectedTouchPos(integer index)
Returns the vector position where the object was touched (specified by index) in region coordinates, or in screen-space coordinates if the object is attached as a HUD.
vectorllDetectedTouchNormal(integer index)
Returns the surface normal vector (perpendicular to the surface) at the touched location specified by index. Can be used with llDetectedTouchBinormal to determine the tangent space.
vectorllDetectedTouchBinormal(integer index)
Returns the surface binormal vector (tangent to the surface, pointing along the positive T (V) direction of tangent space) at the touched location specified by index. Can be used with llDetectedTouchNormal to determine the tangent space.
integerllDetectedLinkNumber(integer number)
Returns the link number (integer) of the triggered event (touches and collisions only) specified by number. Returns 0 for non-linked objects, 1 for the root prim, and 2+ for child prims. Returns 0 if not supported by the event.
keyllDetectedKey(integer number)
Returns the key (UUID) of the detected object or avatar specified by number, or NULL_KEY if number is not a valid index.
llPassTouches(integer pass)
Sets the pass-touches attribute. If pass is TRUE, touch events are passed from child prims to the root; if FALSE (default), they only trigger events in the affected child prim.
llSetClickAction(integer action)
Sets the action (a CLICK_ACTION_* flag) performed when an avatar left-clicks the prim.
llSetTouchText(string text)
Displays the string text instead of 'Touch' in the right-click context menu.

Additional

Constant groups PassMode 3ClickAction 11

See also Feature InputCategory TouchSL Wiki LSL Touch PositionSL Wiki Script library: touch detectionPlanned Recipe: buttons on one prim with touch positions