Difference between revisions of "LlGetVel"

From Second Life Wiki
Jump to navigation Jump to search
(Added example.)
m (this is a less then optimal example but it's what we got)
Line 14: Line 14:
//If you ever want to actually stop an object, use llMoveToTarget(llGetPos(), .1)
//If you ever want to actually stop an object, use llMoveToTarget(llGetPos(), .1)
default {
default {
    state_entry() {
    state_entry() {
          vector spd;
        vector spd;
          while (1 == 1) // Go forever
        {@loop;
              if (llVecMag(spd = llGetVel()) > .001) { //We're accelerating...
            if (llVecMag(spd = llGetVel()) > .001) { //We're accelerating...
                    llApplyImpulse(-spd, 0) //Slow us down.
                llApplyImpulse(-spd, 0) //Slow us down.
              }
            }
          }    }
        jump loop;}
} Code by Xaviar Czervik
     }
}//Code by Xaviar Czervik
</lsl>
</lsl>
|helpers
|helpers
Line 31: Line 32:
|notes
|notes
|permission
|permission
|negative_index
|cat1=Physics
|cat1=Physics
|cat2=Vehicle
|cat2=Vehicle

Revision as of 15:35, 8 February 2008

Summary

Function: vector llGetVel( );

Returns a vector that is the velocity.

Examples

<lsl> //A very simple (and not very effective) way of keeping a physical object in place. //If you ever want to actually stop an object, use llMoveToTarget(llGetPos(), .1) default {

   state_entry() {
       vector spd;
       {@loop;
           if (llVecMag(spd = llGetVel()) > .001) { //We're accelerating...
               llApplyImpulse(-spd, 0) //Slow us down.
           }
       jump loop;}
   }

}//Code by Xaviar Czervik

</lsl>

See Also

Functions

•  llGetAccel
•  llGetOmega

Deep Notes

Search JIRA for related Issues

Signature

function vector llGetVel();