Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetRot returning child prim's rotation instead of avatar's?

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-19-2005 09:07
I have a code written to make a pointer to point towards a target since llLookAt doesn't behave right on HUD attachments. the script itself works fine if it's in a parent prim, but for the way I have my HUD set up, I can't have the pointer as a parent prim. what's going wrong is the llGetRot is returning the child prim's rotation, and not the avatar's. I need it to return my avatar's rotation.


CODE

sensor(integer total_number)
{
vector tarpos = llDetectedPos(0); //target's position
vector mypos = llGetPos(); //my position
float tardist = llVecDist(tarpos, mypos); //distance between both positions
//llSetText("Distance to target:\n" + (string)tardist, <1.0,1.0,1.0>, 1.0); //sets the distance to target text
rotation rot = llRotBetween(<0,0,1>,llVecNorm(tarpos-mypos));
llSetRot(rot/llGetRot()); //We're dividing by the avatar's rotation to correct for the avatar's rotation. otherwise the arrow will point "funky"
llSetText("Target's Position: " + (string) tarpos + "\n My Position: " + (string) mypos + "\n my rotation: " + (string) llGetRot() + "\n where I should rotate to: " + (string) rot,<1,1,1>,1); //debugging text, hence why I know that the llGetRot is returning the child prim's rotation instead of the avatar's rotation.
}
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-19-2005 14:58
There is no way of getting the avatars rotation in a child prim of an attachment, as you can't issolate out the root prims rotation. In one of my scripts where the children need to know the roots local rot so they can always be turned towords the user, the root tells the children it's local rot.
_____________________
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