Difference between revisions of "LlGetVel"

From Second Life Wiki
Jump to navigation Jump to search
m
(cleanup)
Line 9: Line 9:
|caveats
|caveats
|constants
|constants
|examples=
|examples=<lsl>//A very simple (and not very effective) way of keeping a physical object in place.
<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)
//If you ever want to actually stop an object, use llMoveToTarget(llGetPos(), .1)
default {
//Example by Xaviar Czervik
     state_entry() {
 
default
{
     state_entry()
    {
         vector spd;
         vector spd;
         {@loop;
         {
             if (llVecMag(spd = llGetVel()) > .001) { //We're accelerating...
            @loop;
             if (llVecMag(spd = llGetVel()) > .001)
            { //We're accelerating...
                 llApplyImpulse(-spd, 0) //Slow us down.
                 llApplyImpulse(-spd, 0) //Slow us down.
             }
             }
         jump loop;}
         jump loop;
        }
     }
     }
}//Code by Xaviar Czervik</lsl>
}</lsl>
|helpers
|helpers
|also_functions=
|also_functions=

Revision as of 11:37, 4 March 2008

Summary

Function: vector llGetVel( );

Returns a vector that is the velocity of the object.

Velocity reported is relative to the global coordinate frame (the object rotation has no affect on this functions output).

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) //Example by Xaviar Czervik

default {

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

Notes

To get the velocity relative the local frame (the direction the object is pointing), multiply the output of this function with that of it's rotation. <lsl>vector local_vel = llGetVel() * llGetRot()</lsl>

See Also

Functions

•  llGetAccel
•  llGetOmega
•  llGetForce Gets the objects force
•  llGetTorque
•  llGetMass

Deep Notes

Search JIRA for related Issues

Signature

function vector llGetVel();