Difference between revisions of "LlGetRot"

From Second Life Wiki
Jump to navigation Jump to search
m ([~caveats, -helper (simplification)] +also-func)
m (+caveat)
Line 11: Line 11:
|caveats=
|caveats=
* [[llGetRot]] incorrectly reports the avatars rotation when called from the root of an attached object, use [[llGetLocalRot]] for root prims, instead
* [[llGetRot]] incorrectly reports the avatars rotation when called from the root of an attached object, use [[llGetLocalRot]] for root prims, instead
** [[llGetRot]] will return an accurate facing for Avatars seated or in mouselook, but only a rough direction otherwise when called from an attached prim.
|examples=
|examples=
<lsl> //-- rotates an object to face the nearest cardinal direction (N,E,S,W)
<lsl> //-- rotates an object to face the nearest cardinal direction (N,E,S,W)

Revision as of 19:30, 2 April 2012

Summary

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

Returns a rotation that is the prim's rotation relative to the region's axes.

Caveats

  • llGetRot incorrectly reports the avatars rotation when called from the root of an attached object, use llGetLocalRot for root prims, instead
    • llGetRot will return an accurate facing for Avatars seated or in mouselook, but only a rough direction otherwise when called from an attached prim.

Examples

<lsl> //-- rotates an object to face the nearest cardinal direction (N,E,S,W)

//-- assumes build is aligned to root object facing

default{

 state_entry()
 {
   llSay( 0, "Rotate me in edit, then touch to make me face the nearest compass point" );
 }
 touch_start( integer vIntTouches )
 {
    //-- convert our rotation to x/y/z radians
   vector vRadBase = llRot2Euler( llGetRot() );
    //-- round the z-axis to the nearest 90deg (PI_BY_TWO = 90deg in radians)
   llSetRot( llEuler2Rot( <0.0, 0.0, llRound( vRadBase.z / PI_BY_TWO ) * PI_BY_TWO > ) );
 }
}</lsl>

Notes

  • The tooltip in the in-client editor is incorrect, it will work in scripts in objects that are physical.

Deep Notes

Signature

function rotation llGetRot();