User:Brattle Resident
Converting a rotation to a value that can be sent to @setpos:
This function is designed for use in an attachment. It seems to work reliably in a visible attachment; I have some evidence it may not work properly from a HUD attachment. (Or that could be some other unrelated bug.)
<lsl>
float getCurrentAngle() {
rotation myrot = llGetRootRotation(); // theoretically, returns av's rot float angle = llRot2Angle(myrot); vector axis = llRot2Axis(myrot); //OwnerSay("myrot=" + (string)myrot + "; angle=" + (string)angle + "; axis=" +(string)axis); // If axis.z == 1, angle is rotating north from east (E=0,N=PI/2,W=PI) // If axis.z == -1, angle is rotating south from east (E=0,S=PI/2,W=PI) // @setroot requires an angle that rotates east from north (N=0,E=PI/2,S=PI,W=3PI/2 or -PI/2) float newangle; if (axis.z < 0) { newangle = angle + PI_BY_TWO; } else { newangle = PI_BY_TWO - angle; } return newangle;
}
</lsl>
So if you want to rotate the avatar by 90 degrees, you could do: <lsl>
float angle = getCurrentAngle(); angle += PI_BY_TWO; llOwnerSay("@setrot:" + (string)angle + "=force";
</lsl>