Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

More llLookAt Woes

Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
04-09-2007 20:19
Hello,

I'm trying to get an object to patroll an area of radius r. I have it define its starting position as the center, and every 3 seconds it moves like this:

CODE
llSetPos(<0,1,0> * llGetRot() + llGetPos());


which moves it 1 meter in the direction the object faces.

After each movement, the object rotates a little bit, 10 degrees to be specific, so that it doesn't just keep moving in one direction. It does this by:

CODE
eul = <0,0,10>; //10 degrees around the z-axis, in Euler form
eul *= DEG_TO_RAD; //convert to radians
quat = llEuler2Rot(eul); //convert to quaternion

llSetRot(llGetRot() * quat);


The problem that I'm having is that, when it reaches a boundary, I want it to turn back and face the center of the circle, which it already has the vector for. Doing an llLookAt() doesn't make it look in the right direction and llRotLookAt confuses me. Any help?
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
04-10-2007 10:47
Sorry for bumping this thread up a bit, just wanted to know if any of the daytime scripters could help ;) .
_____________________
Other than that, Mrs. Lincoln, how was the play?
Robustus Hax
Registered User
Join date: 4 Feb 2007
Posts: 231
04-10-2007 11:14
I had an easy small script to make an object move to location A, face location B move to B face location C move to C with the RotLookat and it used to work, however now with new updates and such the object will not rotate in certain directions. Im not sure how to go about fixing it, but its def. problems with Linden
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
04-10-2007 11:34
Probably easier just setting the rotation manually, since, according to the wiki, llLookAt no longer functions for non-physical objects.

CODE

// the center of your circular "patrol area"
vector Center;

// Center relative to patroller
vector Offset = Center - llGetPos();

// Make the patroller's local +X axis point at Center.
// Change <1,0,0> if a different axis is desired
llSetRot( llRotBetween( <1,0,0>, Offset ) );
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
04-10-2007 12:02
that works perfectly! thanks so much :)
_____________________
Other than that, Mrs. Lincoln, how was the play?