touch_start(integer num_detected)
This
event is raised when an
agent first touches the
object the
script is
attached to. The number of touching agents is passed to the script in the
num_detected parameter. Information on those objects may be gathered via the
llDetected* functions.
| Event: | Triggered: | Triggered multiple times: |
| touch() | while a user is clicking on the object. | YES |
| touch_start() | when a user starts clicking on the object. | NO |
| touch_end() | when a user stops clicking on the object. | NO |
Notes:
- "Touch" means "click on", not "collide with"; to deal with collisions, use the collision, collision_start, and collision_end events.
- A script containing a touch, touch_start, or touch_end event may be subject to "prim drift" caused by the user dragging the object when they mean to click it. To avoid this, use llSetStatus(STATUS_BLOCK_GRAB, TRUE) to block "grabs".
See also the
llSetTouchText and
llPassTouches functions.
Q: I see a lot of llDetected*(0), which seems like hacky laziness since even though this is a singular event and so unlikely to coincide, it seems possible for two touch starts to be described in a single event. Does it work that way?
A: Yes, multiple touches can be combined into a single event, but since this is rare you can get away with just checking index 0. When you suspect things get clicked a lot and close together, such as perhaps in competitive games, you should use a for or while loop to step though all the avatar references.
You can also time how long the touch went for with this quick hack:
Events