Hi all. As many have experienced, sitting on odd shaped objects are a pain, so I thought I would automate setting up the offset. Here is my plan. I want to sit on object T using animation A. I make a ball B loaded with animation A. I then sit on B, and move B into position over T so that it looks right.
Then I ask the two to sync.
That is, B tells T its location and rotation using a say command using script S1
In response to that, T need to set its llSitTarget using script S2.
Based on the position of T and B, I am able to get the first param for llSitTarget as
(pos(B)-pos(T))/rot(T), and the second param as (rot(B)/rot(T))
This works "reasonable well", but I am some 30cm off, consistently, independent of the shape of T and B. As B is turned I am off in different directions, but never more than these approx 30 cm.
This is the listen part from script S2.
listen( integer channel, string name, key id, string message )
{
vector targetPos = (vector)llList2String(info,0);
rotation targetRot = (rotation)llList2String(info,1);
list myInfo = llGetObjectDetails(llGetKey(),[OBJECT_POS,OBJECT_ROT]);
vector myPos = llList2Vector(myInfo,0);
rotation myRot = llList2Rot(myInfo,1);
vector toTarget = targetPos-myPos;
llSitTarget(toTarget/myRot,targetRot/myRot);
}
What did I overlook?