llAttachToAvatar(integer attachment)
Attaches the
scripted object at the specified
attachment point to the
avatar it has
PERMISSION_ATTACH for. Even though
users other than the owner can grant this
permission, attaching to them will fail with the message "
Script trying to attach to someone other than owner!".
An object must have permission to attach itself.
Call llGetPermissions to see if the object has the
PERMISSION_ATTACH permission; if it doesn't,
llRequestPermissions must first be called to request permissions from the
user.
The
attach event is called with the avatar's
key.
Notes:
- Once an object is attached to the avatar, certain script functionality is disabled. See attachment for more details.
- If there is already an attachment at the attachment point, it will be detached and replaced with the new one.
- The attachment points are (usually) centered on the body part. If an object has not been attached before, it attaches at <0,0,0> offset from the attachment point. If the object has been attached before, it remembers its last attachment offset.
- Attachment points are relative to the object's skeleton, not its surface. This can cause some attachments to look weird. ATTACH_RPEC and ATTACH_LPEC are examples of attachment points with high levels of surface/skeleton drift.
The attachment
parameter can be one of the following
constants (also
integers):
| Constant | Comment |
| ATTACH_CHEST | chest/sternum - ATTACH_LBOOBIE and ATTACH_RBOOBIE don't exist, though there's ATTACH_RPEC and ATTACH_LPEC |
| ATTACH_HEAD | head |
| ATTACH_LSHOULDER | left shoulder |
| ATTACH_RSHOULDER | right shoulder |
| ATTACH_LHAND | left hand |
| ATTACH_RHAND | right hand |
| ATTACH_LFOOT | left foot |
| ATTACH_RFOOT | right foot |
| ATTACH_BACK | back |
| ATTACH_PELVIS | pelvis |
| ATTACH_MOUTH | mouth |
| ATTACH_CHIN | chin |
| ATTACH_LEAR | left ear |
| ATTACH_REAR | right ear |
| ATTACH_LEYE | left eye |
| ATTACH_REYE | right eye |
| ATTACH_NOSE | nose |
| ATTACH_RUARM | right upper arm |
| ATTACH_RLARM | right lower arm |
| ATTACH_LUARM | left upper arm |
| ATTACH_LLARM | left lower arm |
| ATTACH_RHIP | right hip |
| ATTACH_LHIP | left hip |
| ATTACH_RULEG | right upper leg |
| ATTACH_RLLEG | right lower leg |
| ATTACH_LULEG | left upper leg |
| ATTACH_LLLEG | left lower leg |
| ATTACH_BELLY | belly/stomach/tummy |
| ATTACH_RPEC | right pectoral |
| ATTACH_LPEC | left pectoral - as noted above, ATTACH_RPEC and ATTACH_LPEC don't always look like they're attached to the right and left side of the chest, and will appear to float around a little. |
| 31 | HUD Center 2 |
| 32 | HUD Top Right |
| 33 | HUD Top |
| 34 | HUD Top Left |
| 35 | HUD Center |
| 36 | HUD Bottom Left |
| 37 | HUD Bottom |
| 38 | HUD Bottom Right |
Q: Does this have any purpose when attaching from inventory or only for attaching on a touch event or similar thing? Seems like going from inventory doesn't require PERMISSION_ATTACH either.
A: llAttachToAvatar is used for objects that already exist in-world. Objects in your inventory can be thought of as being in an inert, suspended state. They don't actually "exist" until you rez them.
Q: If I attach an object from inventory, will it have PERMISSION_ATTACH right away, or do I have to request it? And what about an object rezzed by an attached object? (For example, if I need to have an attached object rez a HUD element.)
A: You always must request permissions, but some permissions are auto-granted upon request for attachment or sit. BW
Example:
Functions |
Agent/Avatar |
Attachment