LSL Wiki Mirror 10-5-2006: llSetPos

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
llSetPos(vector pos)

Moves the object to position pos. If the calling script resides in a single prim or the root of a linked object, then pos is in region coordinates, which are relative to the simulator's southwest corner. If the script resides in a child prim in a link set, the pos is relative to the root prim of the link set.

Notes


Examples

llSetPos(<128, 128, 25>);

This moves the object to the center of the simulator, at 25m height (unless it's more than 10m away from that point).

while (llVecDist(llGetPos(), targetposition) > 0.001) llSetPos(targetposition);

Note: this does not work for a child prim because llGetPos always returns the location in region coordinates.

Child Objects

For child prims in a linked set, the position is relative to the parent prim's position (object-local coordinates). This relative position can be retrieved using llGetLocalPos.

Example:
llSetPos(<0, 0, 1>);

This moves the child prim to a position 1m upwards along the Z-axis of the parent object.

Q: Shouldn't this be:
llSetPos(llGetPos() + <0, 0, 1>)?
A: No, not for child prims -- their position is always relative to the parent. If you want to move it relative to its current offset from the parent, you'd use:
llSetPos(llGetLocalPos() + <0, 0, 1>);.

Q: Can I use llSetPos on an attachment?
A: Yes, as of SL 1.7 this is possible. Note that relative positioning applies to them as well, including HUD attachments.

Q: It says that in the parent, llSetPos repositions the entire object, and in a child prim, the position is relative to the parent's. Does this mean that there's no way to reposition the parent relative to all the other children?
A: Correct. You could theoretically do something with linking and delinking the parent, but the easiest way to deal with this situation is to not get into it. Design your object in such a way that the parent need not be repositioned relative to its children.

See also llSetPrimitiveParams.


Functions | Dynamics | Link
There are 14 comments on this page. [Display comments/form]