Skip to content
lsl.devlsl.devLSL Dev

llDetectedRot

function
Function syntax
rotation llDetectedRot(
  1. integer number// Index of the detection information.
);
Returns
rotation
Energy
10

Returns the rotation of the detected object or avatar specified by number, or <0.0, 0.0, 0.0, 1.0> if number is not a valid offset index.

Returns <0.0, 0.0, 0.0, 1.0> if number is not valid sensed object.

How to use
rotation result = llDetectedRot(0);
Example 1
32 collapsed lines
//--// get compass facing of Avatar that touches this object //--//
//-- list of compass directions starting at East, rotated clockwise
list gLstCompassPoints = [ "East", "NorthEast", "North", "NorthWest", "West", "SouthWest", "South", "SouthEast" ];
//-- convert rotation to z-axis compass direction
string CompassDirection( rotation rRotBase )
{
integer iCountCompassPoints = llGetListLength(gLstCompassPoints);
//-- convert rotation to a direction
vector vDirection = <0.0, 1.0, 0.0> / rRotBase;
//-- take the direction and determine the z rotation
float fAngle = llAtan2(vDirection.x, vDirection.y);
//-- take the angle and find the compass point
integer iCompassPoint = llRound(fAngle * iCountCompassPoints / TWO_PI);
//-- convert to string
return llList2String( gLstCompassPoints, iCompassPoint );
}
default{
state_entry()
{
llSay( 0, "Touch me to get your compass facing" );
}
touch_start( integer vIntTouchCount )
{
integer vIntCounter = 0;
do
{
llSay( 0,
llDetectedName( vIntCounter )
+ " is facing "
//-- next line gets avatar rotation and converts to compass direction
+ CompassDirection( llDetectedRot( vIntCounter ) ) );
} while ( ++vIntCounter < vIntTouchCount );
}
}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.