Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

look at avatar horizontal or vertical only

Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
05-09-2008 08:52
I'm using this:

default
{
state_entry()
{
llSensorRepeat("", "", AGENT, 20.0, PI, 0.2);
}

sensor(integer total_number)
{
llLookAt( llDetectedPos(0) + <0.0, 0.0, 1.0>, 3.0, 1.0 );
}
}

how do I get it so it only rotates horizontaly


also need another script to rotate only vertically

one prim will follow horizontally and another one will do the same but vertically

Thanks
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-09-2008 10:35
Have you tried 'llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);'? That should allow the prim to rotate only around its z-axis. Likewise 'llSetStatus(STATUS_ROTATE_Z, FALSE);' should allow one to rotate ONLY around its z-axis. Swap axes to taste.

Otherwise, you can try to calculate a suitable rotation by hand. I find the easiest way to do this is to think about which ways you want the prim's local axes to point. For example, this should return a rotation that can be used (e.g. with llRotLookAt()) to point an object's (or child prim if you are careful about factoring in the root prim's rotation) x-axis in the horizontal direction of a point while keeping its y-axis also horizontal (not yet compiled; may require minor syntax fixes):

CODE

rotation horizontalRotPointingAt(vector targetPos)
{
vector relativePos = targetPos-llGetPos();
relativePos.z = 0.0;

if (llVecMag(relativePos) < 0.01)
{
return llGetRot();
}

vector localX = llVecNorm(relativePos);
vector localY = <-localX.y, localX.x, 0.0>; // Same as <0,0,1>%localX; should already be a unit vector

return llAxes2Rot(localX, localY, <0.0, 0.0, 1.0>);
}