Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How do you figure out what way you're facing.

Jade Bard
Registered User
Join date: 7 Jul 2004
Posts: 106
01-11-2006 13:03
What i'm trying to do is rez and object, and have it move to be infront of the person facing the person.

I've figured out the rotation fine, but the problem i run into is how to set it so no matter what way you're facing the object is front of you.

I'm currently using llSetPos() and it only works if they're facing east.

What function could i use to know if they're facing east, west, north, or south?

[Never mind i figured it out]
Candide LeMay
Registered User
Join date: 30 Dec 2004
Posts: 538
01-11-2006 14:04
CODE

default
{
on_rez(integer n)
{
llSensor("", llGetOwner(), AGENT, 96, PI); //look for owner of the object
}

sensor(integer total)
{
vector ownerPos = llDetectedPos(0);
rotation ownerRot = llDetectedRot(0);

float distance = 2.0; //how far in front of owner should it be

vector ownerDirection = llRot2Fwd(ownerRot); //where is the owner looking
//add the distance to owner's position
vector finalPos = ownerPos + <ownerDirection.x * distance, ownerDirection.y * distance, 0>;

//move
while (llVecDist(llGetPos(), finalPos) > 0.001) llSetPos(finalPos);
}
}