Difference between revisions of "LlGetVel"

From Second Life Wiki
Jump to navigation Jump to search
m (movement category)
Line 39: Line 39:
<lsl>vector local_vel = llGetVel() / llGetRot()</lsl>
<lsl>vector local_vel = llGetVel() / llGetRot()</lsl>
|cat1=Physics
|cat1=Physics
|cat2=Vehicle
|cat2=Movement
|cat3
|cat3=Vehicle
|cat4
|cat4
}}
}}

Revision as of 12:45, 14 October 2008

Summary

Function: vector llGetVel( );
0.0 Forced Delay
10.0 Energy

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)

default {

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

Notes

To get the velocity relative the local frame (the direction the object is pointing), divide the output of this function by that of its rotation. <lsl>vector local_vel = llGetVel() / llGetRot()</lsl>

See Also

Functions

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

Deep Notes

Signature

function vector llGetVel();