However, I am running into problems. The script returns a value for the av location, but when that location (relative to the object) is set as the sit target, it doesn't appear to match. In particular, the avatar stands just fine... Save for the fact that he floats a foot in the air. This effect gets worse with shorter avs. Does anyone know why this might be happening, or more to the point, how to fix it? I expect it's something to do with sensing the avatar dimensions and/or bounding box, but I've not been able to come up with anything even remotely close.
And while we're at it, can anyone thing of a better way to automatically adjust the Z location of the sit target, without requiring the user to touch the item first? Any help you could give would be greatly appreciated.
CODE
vector sit_here = <-1,0,0>;
rotation rotate_here = <0,0,0,1>;
string animation = "stand";
key agent;
vector agentloc;
default
{
state_entry()
{
llSitTarget(sit_here,rotate_here);
llSetSitText("Examine");
// Camera settings go here.
}
touch_start(integer total_number)
{
agent = llDetectedKey(0);
agentloc = llDetectedPos(0)-llGetPos();
// Some correction to "agentloc" with llGetAgentSize commands?
llSitTarget(<-1, 0, agentloc.z>,rotate_here);
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
agent = llAvatarOnSitTarget();
if(agent)
{
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION);
}
}
else
{
llStopAnimation(animation);
agent = "";
llResetScript();
}
}
run_time_permissions(integer perm)
{
if(perm)
{
llStopAnimation("sit");
llStartAnimation(animation);
}
}
}