User:Toy Wylie/RLV Documentation/setrot
< User:Toy Wylie | RLV Documentation
Jump to navigation
Jump to search
Revision as of 18:25, 17 August 2012 by Felis Darwin (talk | contribs)
@setrot
Type
General
Implemented
Implemented since RLV version 1.17
Usage
@setrot:<angle>=force
Purpose
Rotates the user's avatar to face the angle given in radians. An angle of 0.0 means "Face North". Keep in mind that an avatar will only rotate if the difference is big enough from the current rotation. The threshold is around 6° to 10°.
See Also
Example 1
<lsl>default
{
touch_start(integer num) { if(llDetectedKey(0)==llGetOwner()) { float angle=llFrand(TWO_PI); llOwnerSay("@setrot:"+(string) angle+"=force"); llOwnerSay("You are now facing "+(string) ((integer) (angle*RAD_TO_DEG))+"° from the north."); } }}</lsl>
Example 2
Direction Vector to Angle
It's very easy to turn a direction vector (such as the distance between two points) into an angle that can be used with this command: <lsl>default {
touch_start(integer num) { //== When the owner touches us, make them face us if(llDetectedKey(0)==llGetOwner()) { vector diff=llGetPos() - llDetectedPos(0); float angle=llAtan2(diff.x, diff.y); // Note that this is X first, then Y, contrary to what documentation would make you think you should use llOwnerSay("@setrot:"+(string) angle+"=force"); llOwnerSay("You are now facing "+(string) ((integer) (angle*RAD_TO_DEG))+"° from the north."); } }}</lsl>