Difference between revisions of "LlLookAt"

From Second Life Wiki
Jump to navigation Jump to search
(+caveat)
Line 11: Line 11:
|caveats=*There is no guarantee that the host objects will wind up pointing at the target. Depending on the shape of the object, the strength and the damping, it may well settle out at a different rotation pointing in a different direction if the damping stops the rotation before the final position is reached.
|caveats=*There is no guarantee that the host objects will wind up pointing at the target. Depending on the shape of the object, the strength and the damping, it may well settle out at a different rotation pointing in a different direction if the damping stops the rotation before the final position is reached.
*If the prim is not the root, then '''target''' will need correction for the root prim's rotation (see example below).
*If the prim is not the root, then '''target''' will need correction for the root prim's rotation (see example below).
*If the object is an attachment, then '''target''' will need correction for the wearer's rotation.
*If the host object is physical and not symmetrical it may cause a recoil effect where the object winds up drifting away from it's original position as well as making the final rotation it settles on less accurate.
*If the host object is physical and not symmetrical it may cause a recoil effect where the object winds up drifting away from it's original position as well as making the final rotation it settles on less accurate.
|constants
|constants
Line 29: Line 30:


<lsl>
<lsl>
// Same as above, but for use inside a child prim.
// Same as above, but for use inside a child prim or the root of an attachment.
// Make the child look at nearest Avatar.
// Make the child or attachment look at nearest Avatar.


default
default

Revision as of 22:59, 18 February 2010

Summary

Function: llLookAt( vector target, float strength, float damping );

Cause object to point its up axis (positive z) towards target, while keeping its forward axis (positive x) below the horizon.

Continues to track target until llStopLookAt is called.

• vector target
• float strength
• float damping seconds to critically damp in

To change the position in the same manner use llMoveToTarget.

Specification

If the object isn't physical, the settings don't seem to have any effect except the force must be > 0. For physical objects, the strength seems to be something like viscosity, not the rotating strength, so the weaker it is the faster the rotation happens. The damping value controls how fast the rotation damps out. Low values relative to the strength make it bouncy, often overshooting the target, high values sluggish. The strength and damping values seem to have no relation to the mass of the object.

Caveats

  • There is no guarantee that the host objects will wind up pointing at the target. Depending on the shape of the object, the strength and the damping, it may well settle out at a different rotation pointing in a different direction if the damping stops the rotation before the final position is reached.
  • If the prim is not the root, then target will need correction for the root prim's rotation (see example below).
  • If the object is an attachment, then target will need correction for the wearer's rotation.
  • If the host object is physical and not symmetrical it may cause a recoil effect where the object winds up drifting away from it's original position as well as making the final rotation it settles on less accurate.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>//Causes Object to look at nearest Avatar. 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 );
   }

}</lsl>

<lsl> // Same as above, but for use inside a child prim or the root of an attachment. // Make the child or attachment look at nearest Avatar.

default {

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

   sensor(integer total_number)
   {
       vector p = llGetPos();
       llLookAt(p + (llDetectedPos(0) + <0.0, 0.0, 1.0> - p) / llGetRootRotation(), 3.0, 1.0);
   }

}

</lsl>

See Also

Functions

•  llRotLookAt
•  llStopLookAt

Deep Notes

All Issues

~ Search JIRA for related Issues
   llRotLookAt & llLookAt do not update the object's bounding box

Signature

function void llLookAt( vector target, float strength, float damping );