Difference between revisions of "LlSetPos"

From Second Life Wiki
Jump to navigation Jump to search
(Created function to bypass bug when moving small amount llSetLocalPos)
Line 5: Line 5:
|func_desc=Moves the object or primitive towards '''pos''' without using physics.
|func_desc=Moves the object or primitive towards '''pos''' without using physics.
|func_footnote=Movement is capped to 10m per call for unattached root prims.{{Footnote|Unless you exploit the undocumented [[warpPos]] bug.}}
|func_footnote=Movement is capped to 10m per call for unattached root prims.{{Footnote|Unless you exploit the undocumented [[warpPos]] bug.}}
|spec=
|spec=This function is available for nonphysical root prims and all child prims. It has no effect on the root prim if the object is physical.
=====Coordinate Frame=====
=====Coordinate Frame=====
*Root prims (or single prim objects)
*Root prims (or single prim objects)
Line 16: Line 16:
|caveats=
|caveats=
*Because of the intermixing of local and regional coordinates with this function, when a prims position is wanted it is best to use [[llGetLocalPos]].
*Because of the intermixing of local and regional coordinates with this function, when a prims position is wanted it is best to use [[llGetLocalPos]].
*This function does not work for physical objects. Use [[llMoveToTarget]] instead.
*This function does not work in the root prim of physical objects. Use a physical function like [[llMoveToTarget]] instead.
|constants
|constants
|examples=
|examples=

Revision as of 23:30, 27 January 2011

Summary

Function: llSetPos( vector pos );

Moves the object or primitive towards pos without using physics.

• vector pos position in region or local coordinates depending on the situation (see #Specification).

Movement is capped to 10m per call for unattached root prims.[1]

Specification

This function is available for nonphysical root prims and all child prims. It has no effect on the root prim if the object is physical.

Coordinate Frame

Caveats

  • This function causes the script to sleep for 0.2 seconds.
  • Because of the intermixing of local and regional coordinates with this function, when a prims 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 llMoveToTarget instead.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llSetPos() doesn't change position for small vectors when called in attachments on Havok4 unless interacted with

Examples

<lsl> //Move the object up 1m when someone touches it. default {

    touch_start(integer i) {
         llSetPos(llGetPos() + <0,0,1>);
    }

} // to bypass the small movement bug use this // - created by Madpeter Zond // notes: it does not check if the movement would go out of limit range for linked prims llSetLocalPos(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);    

}

</lsl>

Notes

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.

See Also

Functions

•  llGetLocalPos Returns the prim's local position if it is attached or non-root (otherwise it returns the global position)
•  llGetRootPosition Gets the root prims position
•  llGetPos Returns the prim's global position, even if it is attached or non-root

Deep Notes

All Issues

~ Search JIRA for related Issues
   llSetPos() doesn't change position for small vectors when called in attachments on Havok4 unless interacted with

Footnotes

  1. ^ Unless you exploit the undocumented warpPos bug.

Signature

function void llSetPos( vector pos );