Difference between revisions of "LlGetRootRotation"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
Line 11: Line 11:
* This function incorrectly (but usefully) returns the avatars region rotation when called in an attachment, use the following instead:
* This function incorrectly (but usefully) returns the avatars region rotation when called in an attachment, use the following instead:


<lsl>
<source lang="lsl2">
//  if called only from the root
//  if called only from the root
     llGetLocalRot();
     llGetLocalRot();
Line 18: Line 18:
//  this alternative works correctly in all scenarios
//  this alternative works correctly in all scenarios
     llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 );
     llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 );
</lsl>
</source>
|constants
|constants
|examples=
|examples=
Simple example to set region rotation of child prim in unattached link set
Simple example to set region rotation of child prim in unattached link set
<lsl>
<source lang="lsl2">
default
default
{
{
Line 32: Line 32:
   }
   }
}
}
</lsl>
</source>
|helpers
|helpers
|also_functions=
|also_functions=

Latest revision as of 01:49, 22 January 2015

Summary

Function: rotation llGetRootRotation( );
0.0 Forced Delay
10.0 Energy

Returns a rotation that is the region rotation of the root prim of the object.

Caveats

  • Returns an accurate facing for Avatars seated or in mouselook, but only a rough direction otherwise when called from an attached prim.
  • When a seated avatar is in mouselook, its rotation is affected by the camera's rotation. There is no way to get the actual rotation of an avatar while seated in mouselook.
  • This function incorrectly (but usefully) returns the avatars region rotation when called in an attachment, use the following instead:
//  if called only from the root
    llGetLocalRot();
//  if called from in a linked object
    llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 );
//  this alternative works correctly in all scenarios
    llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 );

Examples

Simple example to set region rotation of child prim in unattached link set

default
{
  state_entry()
  {
    //Rotate 45 degrees about Y-axis
    rotation globalRot = llEuler2Rot(<0.0, 45.0, 0.0> * DEG_TO_RAD);
    llSetLocalRot(globalRot / llGetRootRotation());
  }
}

Notes

In an attached object, returns region rotation of avatar NOT of the object's root prim. See special cases of rotation.

See Also

Deep Notes

Signature

function rotation llGetRootRotation();