# Difference between revisions of "Talk:LlLookAt"

Void Singer (Talk | contribs) m (→The Math: some base resources) |
Void Singer (Talk | contribs) m (→The Math: minor thought error) |
||

Line 19: | Line 19: | ||

rotation targetRot = llRotBetween( topPoint, targetPoint ); | rotation targetRot = llRotBetween( topPoint, targetPoint ); | ||

llSetRotation( targetRot * currentRot); | llSetRotation( targetRot * currentRot); | ||

+ | targetPoint = llVecNorm( targetPos - basePos ); | ||

}</lsl> | }</lsl> | ||

:the basic idea of how it works (not the exact implementation) is a bit like that... for more complicated specifics, you might want to check out [[geometric]], which has various geometric functions that determine point intersections, and [[llRotBetween]] which has the reference math used in determining the rotation between points<br/>-- '''[[User:Void_Singer|Void]]''' <sup><small>([[User_talk:Void_Singer|talk]]|[[Special:Contributions/Void_Singer|contribs]])</small></sup> 10:10, 1 February 2013 (PST) | :the basic idea of how it works (not the exact implementation) is a bit like that... for more complicated specifics, you might want to check out [[geometric]], which has various geometric functions that determine point intersections, and [[llRotBetween]] which has the reference math used in determining the rotation between points<br/>-- '''[[User:Void_Singer|Void]]''' <sup><small>([[User_talk:Void_Singer|talk]]|[[Special:Contributions/Void_Singer|contribs]])</small></sup> 10:10, 1 February 2013 (PST) |

## Revision as of 11:11, 1 February 2013

I dont understand a **common logic behind llMoveToTarget and llLookAt functions**.
I can use llMoveToTarget in an object attached to Avatar, then avatars moves with an object and so i can drive it to any place i want.
Which is very nice and usefull. I would expect to find same behaviour in llLookAt, so i can from an attachment rotate an Avatar to any position I like. But it is not so, Avatar does not rotate, only moves.
Maybe it is my fault and there is a way to do it, so if anybody knows anything about it please let me know. Thanx in advance.Martinek Martinsyde 17:11, 5 February 2011 (PST)

- There is no way to rotate an avatar with a script. The reasoning being this it would imply moving the default position and angle of the camera, which the user might not agree with. Instead of resolving the murky camera behavior expectations, they just didn't enable the feature at all. --
**Strife**^{(talk|contribs)}10:36, 8 February 2011 (PST)

But they allow to move avatar exactly this way with llMoveToTarget(...).

## The Math

I have been tinkering with this for about 3 hours now and cant figure out what makes llLookAt tick, it seems super simple but that's just because its all in one function. What im working on is a AI like line of sight program using Raycasts and sensors and i need to get the orientation between the ends of the ray. How i usually get the rotation value that llLookAt uses to get its rot, without all the looking. Normally its easy to get the prim to look at the target, give its rotation, and then calculate. but i cant have this looking at everything.

Most of my attempts always end with the same results as adding + <0.0,1.0,0.0>. Its noobish... (unsigned comment)- Krade DimondAK 12:58, 31 January 2013

<lsl>vector targetPoint = llVecNorm( targetPos - basePos ); while (targetPoint != <0.0, 0.0, 1.0>){

vector topPoint = <0.0, 0.0, 1.0>; //-- 1 unit local up rotation targetRot = llRotBetween( topPoint, targetPoint ); llSetRotation( targetRot * currentRot); targetPoint = llVecNorm( targetPos - basePos );

}</lsl>

- the basic idea of how it works (not the exact implementation) is a bit like that... for more complicated specifics, you might want to check out geometric, which has various geometric functions that determine point intersections, and llRotBetween which has the reference math used in determining the rotation between points

--**Void**^{(talk|contribs)}10:10, 1 February 2013 (PST)