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
- Only works on objects with physics disabled.
- Can never move an object below the ground; attempting to do so will cause the object to be placed with its center at ground height.
- Limited to moving no more than 10m per call in any direction. If the distance is more than 10m, the object will move in the direction of the specified position, but will stop after 10m. This makes it very easy to use it for moving a long distance:
- Cannot position an object higher than 768m.
- An object can be moved into an adjoining sim by specifying a position that is outside the sim but inside the above-mentioned 10m range. For example, if the object is in the sim Gibson at <117, 254, 22>, call and the object will move north into Bonifacio at <117, 3, 22> (259 - 256 = 3). To move south, use a negative value: For more information, see global coordinate.
- Delays 0.2 seconds between calls, making the maximum speed traversable with this function 50 m/sec.
- Drains energy. No error is returned if the object failed to move. Use llSetPrimitiveParams with PRIM_POSITION instead if this is a problem.
Examples
This moves the object to the center of the simulator, at 25m height (unless it's more than 10m away from that point).
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:
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