Difference between revisions of "LlGetLocalPos"

From Second Life Wiki
Jump to navigation Jump to search
m (The function was vague and wouldn't work on child prims)
m (added another example)
Line 31: Line 31:
{
{
   llSetPos(llGetLocalPos() + (local_position * llGetLocalRot()));
   llSetPos(llGetLocalPos() + (local_position * llGetLocalRot()));
}
</lsl>
Or:
<lsl>
SetPositionLocalToCurrentPosition(vector local_position)
{
  llSetPos(llGetPos() + (local_position * llGetRot()));
}
}
</lsl>
</lsl>

Revision as of 15:51, 31 December 2010

Summary

Function: vector llGetLocalPos( );

Returns a vector that is the position relative (local) to the root.

If called from the root prim it returns the position in the region unless it is attached to which it returns the position relative to the attach point.

Examples

<lsl> default {

 touch_start( integer vIntTouched )
 {
   string vStrMessage = "The touched prim is ";
   if (llDetectedLinkNumber( 0 ) > 1)
   {
     vStrMessage += (string)llVecMag( llGetLocalPos() ) + "m from ";
   }
   llSay( 0, vStrMessage + "the root prim" );
 }

}

</lsl>

Useful Snippets

There is no function to set the position of a prim local to itself. To set the position of a prim local to itself you would have to do something like: <lsl> SetPositionLocalToCurrentPosition(vector local_position) {

  llSetPos(llGetLocalPos() + (local_position * llGetLocalRot()));

} </lsl> Or: <lsl> SetPositionLocalToCurrentPosition(vector local_position) {

  llSetPos(llGetPos() + (local_position * llGetRot()));

} </lsl>

See Also

Functions

•  llGetRootPosition Gets the root prims global position
•  llGetPos Gets the prims global position
•  llSetPos Sets the prims global position

Deep Notes

Search JIRA for related Issues

Signature

function vector llGetLocalPos();