llSetPos
void llSetPos(vector Position)If the object is not physical, this function sets the position of the prim.
If the script is in a child prim, Position is treated as root relative and the link-set is adjusted.
If the prim is the root prim, the entire object is moved (up to 10m) to Position in region coordinates.
Parameters
-
Position(vector) - Region coordinates to move to (within 10m).
- Root prims (or single prim objects)
- Attached:
posis a local coordinate relative to the attach point. - Not attached:
posis a region coordinate.
- Attached:
- Child prims (non-root prims):
posis a local coordinate relative to the root prim.
Caveats
Section titled “Caveats”- This function has a movement cap of 10m and a time delay of 0.2 seconds per call. Consider using
llSetRegionPosand/orllSetLinkPrimitiveParamsFastinstead. - Because of the intermixing of local and regional coordinates with this function, when a prim’s position is wanted it is best to use
llGetLocalPos. - This function does not work in the root prim of physical objects. Use a physical function like
llMoveToTargetinstead. - If you have explicitly set your object as “static obstacle” for pathfinding, the function will fail with the error in the debug channel: “Unable to set prim position or scale: object contributes to the navmesh.”
Examples
Section titled “Examples”Move Object Up
Section titled “Move Object Up”// Move the object up 1m when someone touches itdefault { touch_start(integer i) { llSetPos(llGetPos() + <0,0,1>); }}Movement Workaround for Small Movements
Section titled “Movement Workaround for Small Movements”// To bypass the small movement bug// Created by Madpeter Zond// Notes: it does not check if the movement would go out of limit range for linked primsllSetLocalPos(vector offset){ vector save = offset; if(offset.x < 0.0) offset.x -= 1; else offset.x += 1; if(offset.y < 0.0) offset.y -= 1; else offset.y += 1; if(offset.z < 0.0) offset.z -= 1; else offset.z += 1; llSetPos(offset); llSetPos(save);}Multiple movement commands can be chained together with llSetPrimitiveParams and PRIM_POSITION. The advantage of doing this is that the script only sleeps once per function call instead of once per movement.