Difference between revisions of "LlApplyImpulse"

From Second Life Wiki
Jump to navigation Jump to search
(Last edit destroyed template. Fixed.)
(an example like that leads to drama.)
Line 7: Line 7:
|p2_type=integer
|p2_type=integer
|p2_name=local
|p2_name=local
|p2_desc=boolean, if {{LSLG|TRUE}}, '''force''' is treated as a [[Viewer coordinate frames#Local|local]] directional vector instead of [[Viewer coordinate frames#Region|region]] directional vector.
|p2_desc=boolean, if [[TRUE}}]], '''force''' is treated as a [[Viewer coordinate frames#Local|local]] directional vector instead of [[Viewer coordinate frames#Region|region]] directional vector.
|func_desc=Applies impulse to object
|func_desc=Applies impulse to object
|return_text|spec
|return_text|spec
Line 13: Line 13:
|examples=
|examples=
<pre>
<pre>
//Rez a physical object, and drop this script in it.
//Rez an object, and drop this script in it.
//This will launch the box at the closest person around.
//This will launch it at the owner.
//Adding llSetDamage(1000.0) would make this similar to an autokiller.
default {
default {
     state_entry() {
     state_entry() {
           llSensor("", "", AGENT, 1000, 1000);
           list p = llGetObjectDetails(llGetOwner(), [OBJECT_POS]);
    }
          if(p != []) {
    sensor(integer num) {
              llSetStatus(STATUS_PHYSICS, TRUE);
          vector pos = llDetectedPos(0); //Their pos
              vector pos = llList2Vector(p, 0);
          vector diff = pos-llGetPos();
              vector direction = llVecNorm(pos - llGetPos());
          diff = diff/llVecMag(diff); //Make this a unit vector.
              llApplyImpulse(direction * 100, 0);
          llApplyImpulse(diff*10000, 0); //Launches the object at the person.
           }
          llApplyImpulse(diff*10000, 0); //Launches the object at the person.
          llApplyImpulse(diff*10000, 0); //Launches the object at the person.
           llApplyImpulse(diff*10000, 0); //Launches the object at the person.
    }
    no_sensor() {
          llOwnerSay("No agents detected within 96m");
     }
     }
}
}

Revision as of 07:52, 29 November 2007

Summary

Function: llApplyImpulse( vector force, integer local );
0.0 Forced Delay
10.0 Energy

Applies impulse to object

• vector force
• integer local boolean, if [[TRUE}}]], force is treated as a local directional vector instead of region directional vector.

Caveats

  • Object must be physical.

Examples

//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);
          }
     }
}

See Also

Functions

•  llApplyRotationalImpulse

Deep Notes

Signature

function void llApplyImpulse( vector force, integer local );