llDetectedTouchPos
vector llDetectedTouchPos(integer Index)Returns the position, in region coordinates, where the object was touched in a triggered touch event.
Unless it is a HUD, in which case it returns the position relative to the attach point.
Parameters
-
Index(integer) - Index of detected information
TOUCH_INVALID_VECTOR(same asZERO_VECTOR:<0.0, 0.0, 0.0>) is returned when:- The avatar’s viewer does not support face touch detection. To check if face touch detection is supported, check the return of
llDetectedTouchFace. - The touch has moved off the surface of the prim.
- The event triggered is not a touch event.
- The avatar’s viewer does not support face touch detection. To check if face touch detection is supported, check the return of
Examples
Section titled “Examples”Basic Example
Section titled “Basic Example”default{ touch_start(integer num_detected) { llWhisper(0, "Pos clicked: " + (string)llDetectedTouchPos(0)); }}HUD Touch Position Helper
Section titled “HUD Touch Position Helper”This function, contributed by Ariu Arai, converts a HUD touch position to a usable coordinate:
vector GetRealTouchPos(vector pos){ // Returns a useful HUD Position Vector from the llDetectedTouchPos() function // USE: vector pos = GetRealTouchPos(llDetectedTouchPos(0)); .. Etc. // This function is intended to be used to move child prims to where the user clicks. // This does not work on the root prim.
integer point = llGetAttached(); vector offset;
if (point == ATTACH_HUD_TOP_RIGHT) offset = <1.0, 0.933,-0.5>; else if (point == ATTACH_HUD_TOP_CENTER) offset = <1.0, 0.000,-0.5>; else if (point == ATTACH_HUD_TOP_LEFT) offset = <1.0,-0.933,-0.5>; else if (point == ATTACH_HUD_BOTTOM_LEFT) offset = <1.0,-0.933, 0.5>; else if (point == ATTACH_HUD_BOTTOM) offset = <1.0, 0.000, 0.5>; else if (point == ATTACH_HUD_BOTTOM_RIGHT) offset = <1.0, 0.933, 0.5>;
return ((offset - llGetLocalPos()) + pos) / llGetLocalRot();}- This function is for the touch category of events only.
- The prim that was touched may not be the prim receiving the event. Use
llDetectedLinkNumberto check for this. - Use
llDetectedTouchFaceto determine which face was touched.
See Also
Section titled “See Also”- llDetectedLinkNumber
- llDetectedTouchFace
- llDetectedTouchST
- llDetectedTouchUV
- llDetectedTouchNormal
- llDetectedTouchBinormal
touch_starteventtoucheventtouch_endevent