llTargetOmega Replacement

From Second Life Wiki
Jump to navigation Jump to search


Function: KeyFramedOmega( vector axis, float spinrate );

Rotates the object/prim around axis at a rate of spinrate in radians per second

• vector axis arbitrary axis to rotate the object around
• float spinrate rate of rotation in radians per second


  • This doesn't make llTargetOmega redundant but in some cases a Key Framed motion may be preferred
  • The routine: "KeyFramedOmega" is easy to use for llTargetOmega: It takes the first two parameters in llTargetOmega: axis and spinrate
  • All viewers will see the same spin and rotation
  • The object will keep the rotation it has when spin is stopped
  • A spin will continue even when the script is deleted


  • The script must be in the root prim
  • It can not spin child prims
  • The object must be convex hull physics type
  • Can not spin physical objects
  • If the center of mass is not at the center of the root, the object will shake and jerk and drift erratically (BUG-7266)


This script shows how to use the routine to start, stop and reverse a spin on repeated touches

// llTargetOmega substitution by Dora Gustafson, Studio Dora 2014

integer P;

KeyFramedOmega( vector axis, float spinrate)
    llSetKeyframedMotion( [], []);
    if ( spinrate )
        float v = TWO_PI/3.0;
        if ( spinrate < 0 ) v = -v;
        list L = [llAxisAngle2Rot( axis/llGetRot(), v), v/spinrate];
        llSetKeyframedMotion( L+L+L, [KFM_DATA, KFM_ROTATION, KFM_MODE, KFM_LOOP]);

    touch_end( integer n)
        P = ++P%4;
        if ( P == 1 ) KeyFramedOmega( <0,0,1>, 2.0);       // Positive spin
        else if ( P == 3 ) KeyFramedOmega( <0,0,1>, -2.0); // Negative spin
        else KeyFramedOmega( <0,0,1>, 0.0);                // Stop spin


The magnitude of axis do not influence the spinrate

See Also

Deep Notes



[[User:Dora Gustafson|Dora Gustafson]] 04:36, 12 August 2014 (PDT)