// ****************************************************************************** // // SimpleSit // // Sets the sit target at a position given in natural sitting coordinates // (x-axis from front to back, y-axis from left to right, z-axis upward) // // Wordsmith Jarvinen, 02 April 2019 // // ****************************************************************************** // Select a position and orientation in natural/normalized sitting coordinates vector myPos = <0.40, 0.0, 0.55>; vector myAngles = <0.0, 0.0, 0.0>; // Capture the rotation that brings the prim from its default orientation to // the natural orientation for sitting with the avatar facing the +X direction vector angles = <0.0, 0.0, 90.0>; default { state_entry () { // Correction terms on local and global Z values // http://forums-archive.secondlife.com/54/6a/153963/1.html vector zCorrectGlobal = <0.0, 0.0, 0.186>; vector zCorrectLocal = <0.0, 0.0, 0.4>; // A bit of scripting magic happens. This includes converting // the rotation correction from degrees to quaternion format // and offseting both the global and local Z-values by documented // correction terms. rotation rotCorrection = llEuler2Rot(DEG_TO_RAD * angles); vector offset = (myPos + zCorrectGlobal) / rotCorrection - zCorrectLocal; rotation rot = llEuler2Rot(DEG_TO_RAD * myAngles) / rotCorrection; // And we set the sit target llSitTarget (offset,rot); } }