Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation to point at some vector?

Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
09-19-2007 19:39
Slowly going crazy here. I want it to rotate an object so it points towards some location.

I put this in a cube:
CODE

default
{
touch_start (integer count)
{
vector here = llGetPos();
vector there = here;
there.y += 5.0;
there.y += 5.0;

llRotLookAt(llRotBetween (there, here), 1, 1);
}
}

When I do this, it barely moves.. Just twitches a little on each axis.

Shouldn't this make the cube point towards x+5, y+5??
Ralph Doctorow
Registered User
Join date: 16 Oct 2005
Posts: 560
09-19-2007 20:53
The problem is the documentation is a bit ambiguous, I tried to clear up the LSL Portal version.

The two vectors are actually directions and are relative to <0, 0, 0>. The forward direction vector is <1, 0, 0> not <0, 0, 0> which doesn't define a direction at all since it is the origin.

Try doing <1, 0, 0> and <5, 5, 0> which is the same direction as <1, 1, 0> or <.1, .1, 0>.

Also your codes adds 5 to y twice, not to x.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
Search the forums...
09-20-2007 08:32
This and other similar questions have been answered many times. Here is how I do it...

there = llGetPos() + <5,5,0>*llGetRot();

I think. i am a little rusty...that's why you should search the forums 8-)
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
09-20-2007 08:45
I think you'll have more luck with llLookAt(), which will do a lot of the math for you. You give it a point, and it points one of the axes at it. So if you have a vector direction, just add that to llGetPos() and feed it into llLookAt().
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
09-20-2007 10:44
llSetRot(llRotBetween(<0.0,0.0,1.0>,llVecNorm(target-llGetPos()))); // point object's Z-axis at target location
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
09-20-2007 17:23
From: Ralph Doctorow
Also your codes adds 5 to y twice, not to x.

/me eeps. Didn't work either way.. :o

Thanks, Guys! Got it all sorted now! :)