Difference between revisions of "LlApplyImpulse"

From Second Life Wiki
Jump to navigation Jump to search
m (I corrected the issue number / caveat for Jira issue: 'LlApplyImpulse' works only in root prim.)
m
Line 34: Line 34:
{{LSL DefineRow||[[llSetForce]]|Set continuous force}}
{{LSL DefineRow||[[llSetForce]]|Set continuous force}}
|notes
|notes
|deepnotes=
==== Unpredictability ====
Taken from [[Simulator User Group/Transcripts/2012.10.05]]
<blockquote>
[16:24] <font color=#440044><b>Andrew Linden</b><nowiki>: the llApplyImpulse() is even more unpredictable</nowiki></font><br>
[16:24] <font color=#440044><b>Andrew Linden</b><nowiki>: because it uses the legacy script "energy budget"</nowiki></font><br>
[16:25] <font color=#440044><b>Andrew Linden</b><nowiki>: which will attenuate the results if the scripted object doesn't have enough "energy" to execute the impulse that it wants</nowiki></font><br>
[16:25] <font color=#440044><b>Andrew Linden</b><nowiki>: also, that llApplyImpulse() has great griefing potential</nowiki></font><br>
</blockquote>
|cat1=Physics
|cat1=Physics
|cat2=Movement
|cat2=Movement

Revision as of 14:37, 8 October 2012

Summary

Function: llApplyImpulse( vector force, integer local );

Applies impulse to object

• vector force
• integer local boolean, if TRUE force is treated as a local directional vector, if FALSE force is treated as a region directional vector

Instantaneous impulse. llSetForce has continuous push. "Instantaneous" seems to mean a one second impulse, as an application of a force (in newtons) equal to the object's mass (in kg) for one second will accelerate it to a velocity of 1 (in meters per second), which appears to be what happens with this function.

Caveats

  • Only works in physics-enabled objects.
  • The magnitude of force may be scaled back by the object's available energy.
  • The maximum magnitude of force is 20.0 and if it exceeds that it will be scaled back.
  • Silently fails when not called from inside the root prim.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl> //Rez an object, and drop this script in it. //This will launch it at the owner. default {

    state_entry() {
         list p = llGetObjectDetails(llGetOwner(), [OBJECT_POS]);
         if(p != []) {
             llSetStatus(STATUS_PHYSICS, TRUE);
             vector pos = llList2Vector(p, 0);
             vector direction = llVecNorm(pos - llGetPos());
             llApplyImpulse(direction * 100, 0);
         }
    }

}

</lsl>

See Also

Functions

•  llApplyRotationalImpulse
•  llSetForce Set continuous force

Deep Notes

Unpredictability

Taken from Simulator User Group/Transcripts/2012.10.05

[16:24] Andrew Linden: the llApplyImpulse() is even more unpredictable
[16:24] Andrew Linden: because it uses the legacy script "energy budget"
[16:25] Andrew Linden: which will attenuate the results if the scripted object doesn't have enough "energy" to execute the impulse that it wants
[16:25] Andrew Linden: also, that llApplyImpulse() has great griefing potential

All Issues

~ Search JIRA for related Issues
   llApplyImpulse now works only in the root prim.

Signature

function void llApplyImpulse( vector force, integer local );