Don't click here unless you want to be banned.

LSL Wiki : llSitTarget

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl423.us.archive.org
llSitTarget(vector offset, rotation rot)

Sets the sit target for the prim (not the object) at offset from the center of the prim and rotated by rot. If offset is ZERO_VECTOR, the sit target is cleared.

After defining a sit target, llAvatarOnSitTarget can be used. The changed event will be called with the CHANGED_LINK flag set when someone sits on the prim, at which time llAvatarOnSitTarget may be called.

Note: like particles, sit targets are a property of the prim, not the script. So if a script gives a prim a sit target, and that script is deleted, the sit target remains. The only way to clear the sit target is by calling llSitTarget(ZERO_VECTOR,ZERO_ROTATION);

Example:
// Avatar will sit slightly above the object's center, 
// facing the direction of the forward axis.
llSitTarget(<0,0,.1>, ZERO_ROTATION);

//This rotates the avatar 90 degrees
llSitTarget(<0,0,0.1>,llEuler2Rot(<0,0,90> * DEG_TO_RAD));

Offset Problems With Sit Animations

It would be nice if one llSitTarget setting would suffice for all occasions. Sadly, it does not, because visual placement of avatar in llStartAnimation is in itself dependent on avatar size, build, and -- surprise -- gender! You may get it just right for your own avi, but the next visitor with different gender sits with unacceptable offset -- or can't sit at all because of it.

It gets worse when using some custom sit animations! The same sit-target and animation can result in relative offset of half a meter, or more, between male and female avatars. The only way to determine if sit target + animation + gender + avi-size is a serious problem is to test and test again. Maybe a compromise target location can split the differences acceptably. Maybe you need to make some placements M or F only. Maybe you can include script runtime tests to dynamically adjust target before (re)setting it, or select alternative animations from a prechosen list.

Teleport Hack

The maximum distance llSitTarget can offset is up to 300m on any axis. This means it can be used to instantly teleport avatars around by having them sit on an object that immediately unsits them again (now at their new position). To activate the "teleporter", the user simply selects "Sit Here" from the object's pie menu. llSetSitText allows selecting a more apt label to replace "Sit Here".

Note: the rotation of the object with the teleport script will usually affect where the teleport takes the avatar. To nullify this rotation, divide ZERO_ROTATION by the rotation of the object:

//Rotational cancel method by Moleculor Satyr
llSitTarget(target * (ZERO_ROTATION / llGetRot()),ZERO_ROTATION / llGetRot());

The location chosen in llSitTarget is a prim-local target, not a global one. To teleport-hack to a specific <x,y,z> position within the sim, subtract the object's region coordinates from the target to obtain a vector that is relative to the object:

//Moleculor Satyr's rotational cancel with a tweak -Tateru Nino, and another -BW
vector target=<100.0, 100.0, 103.5>;
rotation my_rot = llGetRot();
llSitTarget((target - llGetPos()) / my_rot,ZERO_ROTATION / my_rot);

Note: in conditions of high lag and slow communications speed, SL will sometimes put the avatar close to <0,0,0> in the sim for sometime before actually putting the avatar in the sit location.

Also Note: The above example script will need to be reset each time the rotation or position is changed if the target is to be maintained.

Linked Objects With Multiple Sit Targets

How Seats Are Labeled
Wouldn't it be nice if you could label the driver's seat "Drive!" and the passenger's seat "Ride!" But this does not seem possible 8-( . I've used llSetSitText to specify such seat labels. But, regardless, the label of the seat that is the root prim is used for every seat.

Confusingly, despite having its label overriden by the root sit target's label, the scripting of each individual sit target is still intact. You can test this by having each sit target llWhisper a unique message when you sit on it.

How We Choose Our Seats
In a vehicle (or any object) with multiple seats (each seat has a script that sets a sit target), the following method determines which sit target an avatar ends up at:

If the primitive the player clicked on has a sit target and that sit target is not full, that sit target is used.
If the primitive the player clicked on has no sit target, and one or more other linked objects have sit targets that are not full, the sit target of the object with the lowest link number will be used.

So, to make a vehicle that would allow one driver and exactly two passengers:
Link 0 (the root prim) the driver's seat
Link 1 Passenger seat 1
Link 2 Passenger seat 2
Link 3 Ejector (a script that immediately llUnSits an avatar on its sit target)

So, if the vehicle is empty, and a player clicks on any unscripted part of the vehicle to sit, they will end up in the driver's seat (the lowest empty link number with a sit target).

Simple eh?

Q: Can I just set the sit target again to move a sited avatar?
Q: Can I move the child prim the avatar sited on to move the avatar?
A: Those techniques won't work because the avatar starts to behave as a child prim once seated. For a workaround, see llSetLinkPrimitiveParams.




This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Agent/Avatar | Sit
Comments [Hide comments/form]
Linked Objects with Multiple Animated Sit Targets

Usually people use sittargets in combination with animations. Remember that although all prims receive 'changed' events, only one prim actually acquires the permission to animate the 'sitting' AV. So make sure when stopping anmations you actually check if the prim the script is running in, is the one the AV is actually sitting on and has the permission to animate. This can be done using llGetPermissionsKey() != NULL_KEY for instance.
-- DamaniosThetan (2004-07-29 12:27:14)
Teleport hacking large distances can be trouble. With the best of intentions you can land in the wrong sim, not QUITE hit the right target (it seems a little variable. You might get it 9 times out of ten, and fail on the tenth time). Long-distance teleport hacks can create several kinds of ghosting (where two teleport-hacked avs are in the same sim, and close to each-other, but one is not visible to the other because of a confused client). If you're teleport-hacking a long distance upwards (and face it - you probably are) it's best not to be flying when you do it as it seems to increase the likelyhood of position errors with respect to the destination. Oh, and make sure your target is just a little above the destination's floor when you do it.
-- TateruNino (2005-09-07 00:49:02)
Just spent an hour trying to get the rotational cancel tweak to work. All it needed was spaces around the - because of SL buggyness. So I fixed it here.
-- AsterLardner (2006-02-19 12:25:07)
I seem to be having problems using the teleport hack depending on what direction the Avi is facing.
-- DedricMauriac (2006-05-21 21:04:50)
I added a note to the part about stopping the rotation errors (based on the rotation of the prim). It seems resetting is needed after each rotation.
-- BirosTiros (2006-12-16 19:13:40)
I would like to see an actual example of how to get avatars sitting at a specific seat (instead of the child prim they clicked on). Make an example here or extend the wiki vehicle example with multiple seats and link to it from here.
-- cc30044-a.emmen1.dr.home.nl (2007-05-28 06:16:21)
What if an object is made of several prims, and three of them have SIT ON TARGET as default when touched, whereas the root one has llSit Target enabled? Where the avatr is sit?
-- adsl203-145-140.mclink.it (2007-06-02 14:09:28)
Attach a comment to this page: