LlRotLookAt

De DigiWiki.

//-- where vPosTarget is the global position of the object you want to "look" at
llRotLookAt( llRotBetween( <0.0,1.0,0.0>, llVecNorm( vPosTarget - llGetPos() ) ), 1.0, 0.4 ); // Point +Y axis towards vPosTarget
vector detected = llDetectedPos( 0 );
vector pos = llGetPos();
llRotLookAt( llRotBetween( <0.0, 1.0, 0.0>, llVecNorm( <detected.x, detected.y, pos.z> - pos ) ), 1.0, 0.4 );
//-- 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 llSetKeyframedMotion
Outils personnels
  • Cette page a été consultée 647 fois.
donate
Google Ads