LlGetAccel: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
If used in an attachment
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 6: Line 6:
|return_text=that is the acceleration of the object in the [[Viewer coordinate frames#Region|region]] frame of reference.
|return_text=that is the acceleration of the object in the [[Viewer coordinate frames#Region|region]] frame of reference.
|spec
|spec
|caveats=*Returns [[ZERO_VECTOR]] in attachments regardless of the avatar's acceleration.
|caveats=
*Returns [[ZERO_VECTOR]] in attachments regardless of the avatar's acceleration.
*Returns [[ZERO_VECTOR]] in child prims regardless of the linkset's acceleration.
|constants
|constants
|examples=
|examples=
<lsl>
<source lang="lsl2">
//A very simple (and not very effective) way of keeping a physical object in place.
//A very simple (and not very effective) way of keeping a physical object in place.
//If the object is moving when the script is put in the object, then the object will continue to move, so long as it doesn't accelerate.  
//If the object is moving when the script is put in the object, then the object will continue to move, so long as it doesn't accelerate.  
Line 21: Line 23:
         }
         }
     }
     }
}</lsl>
}</source>
|helpers
|helpers
|also_functions=
|also_functions=

Latest revision as of 01:31, 22 January 2015

Summary

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

Returns a vector that is the acceleration of the object in the region frame of reference.

Caveats

  • Returns ZERO_VECTOR in attachments regardless of the avatar's acceleration.
  • Returns ZERO_VECTOR in child prims regardless of the linkset's acceleration.

Examples

//A very simple (and not very effective) way of keeping a physical object in place.
//If the object is moving when the script is put in the object, then the object will continue to move, so long as it doesn't accelerate. 
//If you ever want to actually stop an object, use llMoveToTarget(llGetPos(), .1)
default {
    moving_start(){ 
        vector ac;
        // Go forever         
        while(llVecMag(ac = llGetAccel()) > .001) { //We're accelerating...
            llApplyImpulse(-ac, 0); //Slow us down.
        }
    }
}

See Also

Functions

•  llGetOmega
•  llGetVel
•  llGetTorque
•  llGetMass
•  llGetForce
•  llSetForce
•  llSetTorque
•  llSetForceAndTorque

Deep Notes

Signature

function vector llGetAccel();