Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Point to target (NOT llLookAt!)

Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
12-13-2008 16:30
Hey everyone. I'm trying to find a formula or function or something that will determine which rotation will cause the object to point at a specified target.


Basically llLookAt, but with the X axis instead of the Z axis.


Thanks in advance ;)



P.S. It could be dealing with long ranges, so it needs to be fairly precise...



EDIT: I suspect it could involve switching the X and Z coordinates or something... Not entirely sure.
_____________________
Life is a highway... And I just missed my exit.
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
12-13-2008 16:41
Check in the old wiki, at http://rpgstats.com/wiki/index.php?title=LlLookAt

The sample script there shows you how to use llRotLookAt with any axis.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
12-13-2008 16:53
CODE

vector lookat; // coordinates of point to look at
default
{
state_entry()
{
llSetRot( llRotBetween( < 1.0, 0.0, 0.0 >, llVecNorm(lookat-llGetPos())));
}
}

Enjoy:)
_____________________
From Studio Dora
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
12-13-2008 17:03
Thanks. Very helpful ^_^
_____________________
Life is a highway... And I just missed my exit.