Don't click here unless you want to be banned.

LSL Wiki : llApplyImpulse

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are 38.107.191.112
llApplyImpulse(vector force, integer local)

If an object is physical, this call applies a single push in a specific direction to the object defined by the argument force. If local is true, force is applied along the object's local axis, otherwise it is applied along the global axis.

Note: unlike llApplyRotationalImpulse, llApplyImpulse does work on attachments.

Because there is no air friction, any impulse off the vertical (gravity) axis will cause the object to keep moving forever. Hence, this can be used to set a velocity.

To set the object's velocity using llApplyImpulse():
setVel(vector newVel, integer localAxis)
{
     vector curVel = llGetVel();
     
     if(localAxis)
     {
          rotation rot = llGetRot();
          curVel /= rot; // Un-rotate curVel.
     }

     newVel -= curVel;
     newVel *= llGetMass();

     llApplyImpulse(newVel,localAxis);
}

Compare with llApplyRotationalImpulse.


llApplyImpulse(llGetMass()*<0,0,10>,FALSE);
//10 meters per second upwards
//Gravity will slow the object down immediately and make it fall back

To overcome gravity effects, use a force which, unlike an impulse, is constant over time:

llSetForce(<0,0,9.8>*llGetMass(),FALSE);
// will cancel the effects of gravity

To stop a moving object dead in its tracks, apply an impulse to counter its current impulse:

llApplyImpulse(-llGetMass()*llGetVel(),FALSE);
//This will cancel the speed of an object that has no other forces set on it
//and will cause it to stop in place relative to the ground

Q:Is it possible to apply Impulses to other peoples objects that havn't been scripted to do so?

Limitations

The actual impulse may be less than requested for two reasons.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Dynamics | Force | Impulse
There are 8 comments on this page. [Display comments/form]