llDetectedRot
function
Function syntax
rotation llDetectedRot(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.
rotation result = llDetectedRot(0);Examples
Section titled “Examples”Example 1
32 collapsed lines
//--// get compass facing of Avatar that touches this object //--//
//-- list of compass directions starting at East, rotated clockwiselist gLstCompassPoints = [ "East", "NorthEast", "North", "NorthWest", "West", "SouthWest", "South", "SouthEast" ];
//-- convert rotation to z-axis compass directionstring 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.