Difference between revisions of "LlRotLookAt"

From Second Life Wiki
Jump to navigation Jump to search
(damping limit for physical objects)
m (~description, +helper)
Line 6: Line 6:
|p3_type=float|p3_name=damping
|p3_type=float|p3_name=damping
|func_footnote=To change the position in the same manner use {{LSLG|llMoveToTarget}}.  For physical objects a range between .2 and 1 is good for both parameters.  
|func_footnote=To change the position in the same manner use {{LSLG|llMoveToTarget}}.  For physical objects a range between .2 and 1 is good for both parameters.  
|func_desc=Cause object to point its forward axis towards '''target'''
|func_desc=Cause object to smoothly rotate to '''target''' with '''strength''' resistance at '''damping''' force.


Continues to face '''target''' untill stopped with {{LSLG|llStopLookAt}}.
Continues to face '''target''' untill stopped with {{LSLG|llStopLookAt}}.
|return_text
|return_text
|spec
|spec
|caveats
|caveats=
* In Non-Physical objects this function operates effectively the same as [[llSetLocalRot]].
|constants
|constants
|examples
|examples
|helpers
|helpers=
* If you want a (mostly) smooth constant rate of motion in a non-physical object try this instead
<lsl>
//-- Rotates Object to vRotTarget at vFltRate (in radians per second
//-- vFltRate < ~0.00000003rad/sec, (~0.00002deg/sec) will result in errors (and is just too slow anyway)
//-- vFltRate >= (PI * 5.0)rad/sec, (900deg/sec) will result in a single snap move to vRotTarget
uSteppedRotLookAt( rotation vRotTarget, float vFltRate){
if ((integer)(vFltRate = (llAngleBetween( llGetLocalRot(), vRotTarget ) / (vFltRate / 5.0)))){
rotation vRotStep = llAxisAngle2Rot( llRot2Axis( vRotTarget / llGetLocalRot() ),
                    (1.0 / vFltRate) * llRot2Angle( vRotTarget / llGetLocalRot() ) );
vFltRate = (integer)vFltRate;
do{
llSetLocalRot( vRotStep * llGetLocalRot() );
}while( --vFltRate );
}
llSetLocalRot( vRotTarget );
} //-- for fixed time on any rotation try llKeyframeMotion
</lsl>
|also_functions=
|also_functions=
{{LSL DefineRow||[[llLookAt]]}}
{{LSL DefineRow||[[llLookAt]]}}

Revision as of 04:32, 7 October 2011

Summary

Function: llRotLookAt( rotation target, float strength, float damping );

Cause object to smoothly rotate to target with strength resistance at damping force.

Continues to face target untill stopped with llStopLookAt.

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

To change the position in the same manner use llMoveToTarget. For physical objects a range between .2 and 1 is good for both parameters.

Caveats

  • In Non-Physical objects this function operates effectively the same as llSetLocalRot.
All Issues ~ Search JIRA for related Bugs

Examples

Useful Snippets

  • If you want a (mostly) smooth constant rate of motion in a non-physical object try this instead

<lsl> //-- Rotates Object to vRotTarget at vFltRate (in radians per second //-- vFltRate < ~0.00000003rad/sec, (~0.00002deg/sec) will result in errors (and is just too slow anyway) //-- vFltRate >= (PI * 5.0)rad/sec, (900deg/sec) will result in a single snap move to vRotTarget uSteppedRotLookAt( rotation vRotTarget, float vFltRate){ if ((integer)(vFltRate = (llAngleBetween( llGetLocalRot(), vRotTarget ) / (vFltRate / 5.0)))){ rotation vRotStep = llAxisAngle2Rot( llRot2Axis( vRotTarget / llGetLocalRot() ), (1.0 / vFltRate) * llRot2Angle( vRotTarget / llGetLocalRot() ) ); vFltRate = (integer)vFltRate; do{ llSetLocalRot( vRotStep * llGetLocalRot() ); }while( --vFltRate ); } llSetLocalRot( vRotTarget ); } //-- for fixed time on any rotation try llKeyframeMotion </lsl>

Notes

  • For physical objects, damping seems to be limited at 1.0; setting it to greater value has the same effect as if it was 1. Tested 21 October 2010 on server version 10.10.18.212360.

See Also

Functions

•  llLookAt
•  llStopLookAt

Deep Notes

All Issues

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

Signature

function void llRotLookAt( rotation target, float strength, float damping );