Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Correction for height in Avatar positions?

Moriash Moreau
Registered User
Join date: 1 Jan 2005
Posts: 39
02-15-2005 15:35
Has anyone had much luck with determining the correct Z coordinates of an avatar's position on the fly? I'm trying to come up with a script to sense an av's coordinates in relation to an object, and set those coordinates as the sit location for that object. I'm going to build this into a small, detailed object, in order to take advantage of the camera controls for a fixed close-up view. The object elevation can vary, as it will be dropped on random table tops. Ideally, I'd like for the avatar to appear to stand in front of the object normally while the user is examining the item.

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);
}
}
}
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
02-15-2005 15:52
Try this: http://secondlife.com/badgeo/wakka.php?wakka=llGetAgentSize
_____________________
---
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-15-2005 17:45
llGetAvatarSize isn't all that useful.
Use llGetBoundingBox as that will give you the distance from pelvis to the ground and the pelvis and the top of the head. (thats using the z cords from the list of vectors returned)
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey